On previous posts we have created Docker Containers based on Linux Centos 7, Apache Web Server, and PHP.
This time we are going to create a new container with PHP 7.3. The previous containers were using earlier versions of PHP.
As you can see on the Dockerfile below, its content is quite similar to the one created for the previous version of PHP.
You can also download this Dockerfile here
FROM centos:7 # Install Apache RUN yum -y update RUN yum -y install httpd httpd-tools # Install EPEL Repo RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ && rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm # Install PHP RUN yum --enablerepo=remi-php73 -y install php php-bcmath php-cli php-common php-gd php-intl php-ldap php-mbstring \ php-mysqlnd php-pear php-soap php-xml php-xmlrpc php-zip # Update Apache Configuration RUN sed -E -i -e '/<Directory "\/var\/www\/html">/,/<\/Directory>/s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf RUN sed -E -i -e 's/DirectoryIndex (.*)$/DirectoryIndex index.php \1/g' /etc/httpd/conf/httpd.conf EXPOSE 80 # Start Apache CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
• The first part of the Dockerfile defines that we will be using Centos 7, and then,
we proceed to install the "httpd" and "httpd-tools" packages. (The Apache Web Server)
• Then we download PHP from the EPEL Repository.
• After that we update the Apache configuration file.
• And lastly we indicate to start the web server by running the httpd command.
Now we create the Docker Image.
docker build -t image_apache .
Then we create the Docker Container.
Notice that we need to indicate the path of our local folder that will be served as the root of the Apache Web Server, which in this example is /path_to/my_website. Replace it with the location of your site's root folder.
docker run -tid -p 4000:80 --name=container_apache -v /path_to/my_website:/var/www/html image_apache
After the Docker Container is created, we can go to the url http://localhost:4000 to open the local website.
Check the Dockerfile on Github here.
Download the Image from Docker Hub here.