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

Apache HTTPD + PHP7.3 replace php settings

Problem

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

Solution

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 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

# 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

EXPOSE 80

# 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