title: Run PHP application in Apache server using PHP-FPM
body: <p>We have a php application which was running fine using
   Docker Image : </p>
  
  <blockquote>
    <p>php:7.2-apache-stretch</p>
  </blockquote>
  
  <p>We now have to make use of the below image for better performance and make the application work as it was before .</p>
  
  <blockquote>
    <p>php:7.2.17-fpm-stretch</p>
  </blockquote>
  
  <p>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 . </p>
  
  <p>There is many other steps . I have just added the instructions which I have updated in the Dockerfile.</p>
  
  <pre><code> FROM php:7.2.17-fpm-stretch
  
  RUN apt-get update &amp;&amp; apt-get install -y apache2 wget
  
  RUN cd /tmp &amp;&amp; wget http://mirrors.kernel.org/ubuntu/pool/multiverse/liba/libapache-mod-fastcgi/libapache2-mod-fastcgi_2.4.7~0910052141-1.2_amd64.deb &amp;&amp; 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"
  </code></pre>
  
  <p>The info.php contains <code>&lt;?php phpinfo( ); ?&gt;</code> . In the run.sh script , we start the php-fpm service and apache2 as below</p>
  
  <blockquote>
    <p>php-fpm -D</p>
    
    <p>/usr/sbin/apachectl -D FOREGROUND</p>
  </blockquote>
  
  <p>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 . </p>
  
  <p>The Content in the vhost.conf file.</p>
  
  <pre><code>&lt;FilesMatch \.php$&gt;
    SetHandler "proxy:fcgi://localhost:9000"
  &lt;/FilesMatch&gt;
  </code></pre>
  
  <hr>