[BlueOnyx:20116] PHP-FPM and .php in url - file not found

Darren Wolfe darren at intersys-group.com
Tue Sep 27 20:09:53 -05 2016


Hi,

I've been working on an issue with 5209r, the solarspeed php 5.6 package, with a vsite configured to use php-fpm running wordpress in a multi-site configuration, though this issue is more generalised than wordpress. It's solved, and I would like to see the solution added to BX.

With the configuration above, going to the url http://www.d.com/x gives us a wordpress not found error as the htaccess rewrite rules do their job.

Go to http://www.d.com/x.php where x.php does not exist and you get a simple "file not found" error generated by php-fpm. No htaccess processed, wordpress never gets given the url.

If I go to http://www.d.com/wp-admin I am redirected to http://www.d.com/wp-login.php which exists, and away we go.
In multisite if I go to http://www.d.com/othersite/wp-admin I am redirected to http://www.d.com/othersite/wp-login.php which does not exist (othersite is not a real directory) and so I get the basic "file not found" error and nothing else.

If we examine the site specific httpd config we see the line:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9042/home/.sites/137/site42/web/
This says - any url with .php in it, pass to fcgi. This is why we get "file not found" instead of the wordpress not found error.

Therefore, what we need is for httpd to first check if the target url exists and only if it does, and then only if it it has .php in it, pass it to fcgi - and so we get:

RewriteCond /home/.sites/137/site42/web/%{REQUEST_FILENAME} -f
RewriteRule ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9042/home/.sites/137/site42/web/$1 [L,P]

This will now check to see if that url exists on the server, if it does then it proceeds as before - check if it contains .php and then pass to fcgi if it does. If it does not then we just continue processing, thus allowing htaccess to be processed, and thus wordpress handles the url correctly and so multisite works.

I used this: http://serverfault.com/questions/450628/apache-2-4-php-fpm-proxypassmatch for reference (stole from)

I should add that using PHP (DSO) + mod_ruid2 avoids the issue too, but where is the fun in just switching to that?






More information about the Blueonyx mailing list