I got to scratch my head on this one for a while. If you’re writing a PHP-FPM config for Apache 2.4, don’t use the ProxyPassMatch
directive to pass PHP requests to your FPM daemon.
This will cause you headaches:
# don't <IfModule mod_proxy.c> ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/ </IfModule>
You will much rather want to use a FilesMatch
block and refer those requests to a SetHandler
that passes everything to PHP.
# do this instead # Use SetHandler on Apache 2.4 to pass requests to PHP-PFM <FilesMatch \.php$> SetHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch>
Why is this? Because the ProxyPassMatch
directives are evaluated first, before the FilesMatch
configuration is being run.
That means if you use ProxyPassMatch
, you can’t deny/allow access to PHP files and can’t manipulate your PHP requests in any way anymore.
So for passing PHP requests to an FPM daemon, you’d want to use FilesMatch
+ SetHandler
, not ProxyPassMatch
.