Problems with fastcgi php migration

Ian M. Evans ianevans at digitalhit.com
Fri Mar 14 03:47:34 MSK 2008


Just wanted to reiterate my activities tonight.

I've spent so much time looking at the debug logs this evening, I feel 
like I've become one with my monitor.

In the location that Igor suggested for finding an extensionless php 
file in multiple sub dirs, nginx has been able to find and run the file at:
/subdir/subdir/test

A-OK, file runs as expected, people cheer in the streets.

I changed the test file from it's original script to just a phpinfo(); 
to make sure nothing in the script could have been causing the failure.

/subdir/subdir/test gave us the phpinfo()

/subdir/subdir/test/ and /subdir/subdir/test/1 create a blank screen. 
There's a 200 OK response, the fastcgi server sends:
http fastcgi header: "X-Powered-By: PHP/5.2.5"
http fastcgi parser: 0
http fastcgi header: "Content-type: text/html" and the static location 
even sends the favicon.ico over. Just no phpinfo() or any html of any kind.

I'm perplexed.

I've also noticed weird things in the script capture portion of the debug.

On /subdir/subdir/test/ <--with trailing slash, there was:
32720#0: *75364 http script regex: 
"^/(?:.+/)?(testgalleries|galleries|poll|news|photos|test)(/.*)"
32720#0: *75364 http script if
32720#0: *75364 http script complex value
32720#0: *75364 http script copy: "/hars"   <-- what's this?
32720#0: *75364 http script capture: "/test"
32720#0: *75364 http script set var
32720#0: *75364 http script complex value
32720#0: *75364 http script capture: "/"
32720#0: *75364 http script set var

Where did /hars come from?

On /subdir/subdir/test/1 there was:

32720#0: *76311 http script regex: 
"^/(?:.+/)?(testgalleries|galleries|poll|news|photos|test)(/.*)"
32720#0: *76311 http script if
32720#0: *76311 http script complex value
32720#0: *76311 http script copy: "/" sr" <-- what's this?
32720#0: *76311 http script capture: "/test"
32720#0: *76311 http script set var
32720#0: *76311 http script complex value
32720#0: *76311 http script capture: "/1"

Where did "/" sr" come from. I'm guessing this weird extra info may be 
screwing things up?

Thanks to all on the list for putting up with this long thread. I've 
been running the extensionless php files (in any subdir) for almost a 
decade with the simple Apache directive:

<Files photos>
ForceType application/x-httpd-php
</Files>

I didn't realize that getting the same thing to work in nginx would be 
such a mindbender, but I'm willing to stare at the monitor and try all 
of Igor's and the list's suggestions because the speed, memory footprint 
and general beauty of nginx make the journey worthwhile. Please keep 
those suggestions coming. :-)

As I wrote to Igor earlier today, we're 99.99% there and I'm sure we'll 
make it. I know I'm not the only one in the Apache world that's used 
extensionless php scripts so I'm sure this will finally make a wiki 
entry that will encourage more folks to make the jump to nginx.

As a reminder, here's Igor's latest suggestion for the location:

location ~ /(testgalleries|galleries|poll|news|photos|test)(/|$) {
root /usr/local/apache/htdocs;
set  $script_name  $uri;
set  $path_info    "";

if ($uri ~ ^/(?:.+/)?(testgalleries|galleries|poll|news|photos|test)(/.*)) {
set  $script_name  /$1;
set  $path_info    $2;
fastcgi_pass 127.0.0.1:10004;
}

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
#fastcgi_param  PATH_TRANSLATED    $document_root$fastcgi_script_name;
#fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_param  SCRIPT_FILENAME  $document_root$script_name;
fastcgi_param  PATH_INFO        $path_info;
fastcgi_param  REDIRECT_STATUS    200;
fastcgi_pass 127.0.0.1:10004;
}

I wondered briefly if:
set  $script_name  /$1; was a typo but changing it to $1 doesn't fix it 
either.

Thanks everyone.





More information about the nginx mailing list