Problems with fastcgi php migration

Ian M. Evans ianevans at digitalhit.com
Sun Mar 9 06:14:16 MSK 2008


Thought I'd rename this thread since the problem has morphed beyond the 
original thread "Can fastcgi_index be used with multiple filenames?". 
I'll reiterate some things first and then pass on a few things I've 
discovered this afternoon that are new roadblocks.

Again, the site has been humming along for months as a static serving 
nginx frontend passing everything else back to Apache handling PHP.

In our apache setup we handle .php, .shtml and a few extensionless files 
as PHP. Examples of extensionless filenames include galleries, polls, 
reviews, etc.

When I speak of the extensionless files, I mean that:

/galleries/1/123 is actually a PHP script file named galleries that 
takes the PATH_INFO (we use cgi.fix-pathinfo = 1) of /1/123 and works 
with that to create a page. Other examples would be /reviews/1, 
/polls/12...but, see #3 below.

When I tried to take Apache out of the question I changed the test.conf 
with:

location / {
root /usr/local/apache/htdocs;
index index.shtml index.php;
include /usr/local/nginx/conf/fastcgi.conf;
fastcgi_pass 127.0.0.1:10004;
}
			
location ~* ^.+\.(jpg|...static file list...)$ {
root /usr/local/apache/htdocs;
error_page 403 /dhe403.shtml;
expires 30d;
valid_referers  none  blocked  *.example.com example.com;
if ($invalid_referer) {
return   403;
}
}

The idea was that anything that wasn't a static file was being passed on 
to be handled by fastcgi.

When I first posted about this early Saturday morning, I was having no 
problems having fastcgi run /galleries/1/123 but it wouldn't try to 
locate either index.shtml or index.php in real directory situations like 
example.com/ or example.com/webmail. Actually going to 
example.com/index.shtml or example.com/webmail/index.php would run 
through fastcgi but not specifying them wouldn't, I'd get "No input file 
specified."

Igor suggested adding:

location \.(php|shtml)$ {
fastcgi_pass  ...
# fastcgi_index is not needed here at all
}

after the location / {
...
}

block but that didn't work. We then tried:

location ~ \.(php|shtml)$ {

But that didn't work either. Still "No input file specified" when it 
should be looking for index.shtml or index.php.

A few other things I just noticed:

1) It looks like some of the extensionless files need:
$_SERVER['PATH_INFO'] = substr( $_SERVER['REQUEST_URI'], 
strlen($_SERVER['SCRIPT_NAME'] ) ); to work with PATH_INFO properly.

2) I have a custom 404 set up in the server area:

error_page 404 /dhe404.shtml;

It's a PHP file as well. When I tried to get a nonexistent page, it too 
came back with "No input file specified".

3) On /testgalleries/123/444 we get:
_SERVER["PATH_INFO"] /123/444

but on /testgalleries by itself we get:
_SERVER["PATH_INFO"]	/testgalleries

Obviously this is a bit of a problem as it should be empty.

Thanks for any advice. Can't wait until I move the whole site over to 
nginx and drop Apache.





More information about the nginx mailing list