Simplified:
Apache httpd maps the incoming request to a location on the web servers file system (i.e. after parsing the DocumentRoot
and any/all applicable Alias
, Location
, mod_rewrite and other expansions).
When that request maps to a PHP file, Apache httpd passes the filesystem location of that file to PHP-FPM for processing and returns the output PHP-FPM generates to the site visitor.
So when your Apache config for example looks like:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/www.example.com
DirectoryIndex index.html index.php
Alias "/my-app" "/var/www/apps/my-app/release-2.3"
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.2-fpm.sock|fcgi://localhost/"
</FilesMatch>
</VirtualHost>
The directory /var/www/apps/my-app/release-2.3
does not have a index.html
, but contains an index.php
and possibly other data for your web application.
Thus a request for http:///www.exaple.com/my-app
will map to a PHP file on the file system, to /var/www/apps/my-app/release-2.3/index.php
That location is passed to PHP-FPM.
The equivalent of "please parse /var/www/apps/my-app/release-2.3/index.php
for me"
Apache does not send to contents of /var/www/apps/my-app/release-2.3/index.php
to PHP-FPM. That has several reasons: but one is that only rarely a PHP application consists of only the contents of a single PHP file. Typically other parts of the application code get loaded with include
and/or require
PHP directives and the PHP interpreter, PHP-FPM will need to load those files as well.
When you run PHP-FPM in a docker container, you will need to make sure that your PHP sources are available and get mapped to the same file-system location as where the PHP sources reside on the web server.