Apache: "File Not Found" after setting up php-fpm chroot

This is resolved. There were two issues with my above code.

Issue #1 - Only Apache 2.4.10 and above can support sockets

The default version of Apache that comes in the base CentOS repositories (Apache 2.4.6) only support TCP ports. The above code is therefore incorrect, and the listen directive in the php-fpm config file needed to be changed to something like this:

listen = 127.0.0.1:9001

I also made the appropriate change in my http.d conf file, but in addition, I also switched to using the ProxyPassMatch directive instead of using the FilesMatch directive. So my code then became:

ProxyPassMatch "^/(.*\.php)$" "fcgi://127.0.0.1:9001/site1.com"

Note that this code is still wrong... see below

Moving on...

Issue #2 - Relevant Paths

The path in the ProxyPassMatch directive (or, in the case of my older code using the FilesMatch directive) inside my http.d conf file becomes relative to the chroot. It is not relative to the www document root (if different).

So my code in my http.d conf file became:

ProxyPassMatch "^/(.*\.php)$" "fcgi://127.0.0.1:9001/www/$1"

And voila! I have a php-fpm chroot.


php-fpm has a bug with chroot and path.

for example with index.php in www

chroot = /home/www/site1.com
chdir = /www

with this config php-fpm write this path :

/home/www/site1.com/home/www/site1.com/www

one solution is to create a symbolic link in shell :

cd /home/www/site1.com
mkdir -p home/www
cd home/www
ln -s /home/www/site1.com site1.com

but it is not clean.

https://bugs.php.net/bug.php?id=55322

https://bugs.php.net/bug.php?id=62279