My PHP Docker container is not processing files and the source is being returned instead.
The following content is being returned instead of being executed:
<?php
phpinfo();
?>
Output of docker ps, to show that both my containers are running and listening on their respective ports:
dan@server:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e5e235112a35 php:7.2-fpm "docker-php-entrypoi…" 23 minutes ago Up 23 minutes 0.0.0.0:9000->9000/tcp php
2196a8f251d3 httpd "httpd-foreground" 5 days ago Up 33 seconds 0.0.0.0:80->80/tcp apache
Virtualhost configuration, notice the FilesMatch directive passing the PHP to the container.
<Directory /usr/local/apache2/htdocs/default>
Options -Indexes
AllowOverride All
Require all granted
</Directory>
<VirtualHost 192.168.2.35:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /usr/local/apache2/htdocs/default
<FilesMatch \.php$>
SetHandler "proxy:fcgi://php:9000"
</FilesMatch>
LogLevel trace1
ErrorLog logs/error.default.ca.log
CustomLog logs/access.default.ca.log combined
</VirtualHost>
Apache log, showing that the file is being served by Apache.
192.168.2.30 - - [22/Dec/2018:02:40:49 +0000] "GET /default/index.php HTTP/1.1" 200 24
Edit
I'm attempting to run Apache, PHP and MariaDB in separate containers. I had Apache running first, and now, I'm attempting to attach PHP.
Eventually, I wanted to add Nextcloud, which IIRC, has a container without Apache where I could reuse my existing container.
My PHP Dockerfile
FROM php:7.2-fpm
RUN buildDeps=" \
libmcrypt-dev \
default-libmysqlclient-dev \
libjpeg-dev \
libldap2-dev \
libmemcachedutil2 \
libpng-dev \
libpq-dev \
libxml2-dev \
" \
&& apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y $buildDeps $runtimeDeps \
&& pecl install mcrypt-1.0.1 && docker-php-ext-enable mcrypt.so \
&& docker-php-ext-install bcmath bz2 calendar iconv json intl mbstring mysqli opcache pdo_mysql soap zip \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd \
&& apt-get purge -y --auto-remove $buildDeps \
&& rm -r /var/lib/apt/lists/*