We have a php application which was running fine using Docker Image :
php:7.2-apache-stretch
We now have to make use of the below image for better performance and make the application work as it was before .
php:7.2.17-fpm-stretch
As this image does not have apache in it . I updated the Dockerfile starting from the installation of apache2 and related packages based on various forums .
There is many other steps . I have just added the instructions which I have updated in the Dockerfile.
FROM php:7.2.17-fpm-stretch
RUN apt-get update && apt-get install -y apache2 wget
RUN cd /tmp && wget http://mirrors.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb && dpkg -i libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb;apt-get install -f
RUN a2enmod actions proxy_fcgi fastcgi
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
COPY info.php /var/www/html/info.php
COPY run.sh /app/run.sh
# EXPOSE 9000
RUN chmod 755 /app/run.sh
CMD "/app/run.sh"
The info.php contains <?php phpinfo( ); ?> . In the run.sh script , we start the php-fpm service and apache2 as below
php-fpm -D
/usr/sbin/apachectl -D FOREGROUND
previously I was trying to access the app from the port which was mapped to 9000 ( fpm ) . When I accessed the correct port where apache was running , I was able to view info.php .
The Content in the vhost.conf file.
<FilesMatch \.php$>
SetHandler "proxy:fcgi://localhost:9000"
</FilesMatch>
I got your new configuration working using this dockerfile:
FROM php:7.2.17-fpm-stretch
RUN apt-get update && apt-get install -y apache2 wget
RUN cd /tmp && wget http://mirrors.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb && dpkg -i libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb;apt-get install -f
RUN a2enmod actions proxy_fcgi fastcgi
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
COPY info.php /var/www/html/info.php
COPY run.sh /app/run.sh
RUN chmod 755 /app/run.sh
EXPOSE 80
CMD "/app/run.sh"
The command I ran was:
docker run -P -d --rm <php-image>
The exposed ports are:
0.0.0.0:32773->80/tcp, 0.0.0.0:32772->9000/tcp
I was able to access info.php using http://localhost:32773/info.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With