Forum Navigation
You need to log in to create posts and topics.

Apache HTTPD + PHP7.3 replace php settings


User wants to create container with Apache httpd and PHP 7.3 and also update php configuration and httpd settings


Use sed to change the default settings

FROM centos:7

# Install Apache
RUN yum -y update
RUN yum -y install httpd httpd-tools

# Install EPEL Repo
RUN rpm -Uvh \
&& rpm -Uvh

# 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

# Update and replace Php Settings
RUN sed -E -i -e ‘s/max_execution_time = 30/max_execution_time = 60/’ /etc/php.ini \
&& sed -E -i -e ‘s/memory_limit = 128M/memory_limit = 256M/’ /etc/php.ini \
&& sed -E -i -e ‘s/post_max_size = 8M/post_max_size = 32M/’ /etc/php.ini \
&& sed -E -i -e ‘s/upload_max_filesize = 2M/upload_max_filesize = 64M/’ /etc/php.ini


# Start Apache
CMD [“/usr/sbin/httpd”,”-D”,”FOREGROUND”]

Build the container

docker build -t image_httpd .

run the container

docker run -tid -p 8080:80 –name=container_httpd -v /home/tracston/website:/var/www/html image_httpd


If you have found my website, guides, articles or videos useful, please buy me a coffee