I typed a compose file which run a httpd like a web-server,
nginx like a proxy to httpd,
and php-fpm like a *.php files interpreter.
when I open localhost on browser I can look files on /var/www/html,
but when I try to open any php file,
I see only php code.
php-fpm started on 9000,
and I check that by run
nmap -p 9000 php
from another httpd container,
checking port return the positive message.
My HTTPD conf file contains the follow lines:
<FilesMatch .php$>
SetHandler "proxy:fcgi://php:9000"
</FilesMatch>
My custom httpd conf file:
<VirtualHost *:8080>
DocumentRoot /var/www/html
ServerName page.com
<FilesMatch .php$>
SetHandler "proxy:fcgi://php:9000"
</FilesMatch>
<Directory "/var/www/html">
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
2
Answers
compose:
nginx conf:
apache:
It would be useful to see your
docker-compose.yml
. However, here is a working setup that you can use to get started. I use this stack with only two services: NGINX and PHP/FPM.🗎
docker-compose.yml
That’s using the following volume mounts:
./app:/var/www/html
on thephp
service so that PHP/FPM can run over the PHP files;./app:/var/www/html
on thenginx
service for serving static files; and./default.conf:/etc/nginx/conf.d/default.conf
on thenginx
service for the NGINX configuration.🗎
default.conf
That establishes a reverse proxy from port 80 to the PHP service running on port 9000.
🗎
index.php
🗎
static.html