5

I'm trying to set up a global location in nginx. It all works perfectly right now, other than PHP scripts requiring fastcgi. They're running a 404.

Is there a way I can see the exact path it's accessing so I can try to debug this a bit and figure out what I'm doing wrong?

Rob
  • 2,393
  • 9
  • 33
  • 52
  • See [this question](http://serverfault.com/questions/359399/php-errors-via-fastcgi-with-nginx-on-ubuntu-linode/359439#359439) for a possible approach to debugging. You can setup an error log in fastcgi and increase the verbosity of nginx's logs. Out of curiousity, what does you mean by 'global' - `location /` or actually a location block used by many virtual hosts? (I'd start by checking the root parameter is set and available in your location block). – cyberx86 Mar 31 '12 at 01:11
  • @cyberx86 I'll look at that, thanks. It's a location block used by many vhosts as you said. – Rob Mar 31 '12 at 01:46

2 Answers2

8

There is no access log for FastCGI, because it isn't a program, it's a protocol. For debugging the PHP fastcgi handler, I've usually resorted to strace -- it usually shows me what file is trying to be accessed, and it's not hard to work out how it went wrong from there. Nginx's request processing debug logging is often instructive, too.

Using strace for this is pretty straightforward -- you just strace the PHP FCGI workers and limit yourself to read/write calls with -e trace=read,write. Upping the string print size with -s 4096 is also a good idea, so you get the entire FCGI packet rather than just the first few bytes.

womble
  • 96,255
  • 29
  • 175
  • 230
  • How could I use `strace` to track the HTTP request? – Rob Mar 31 '12 at 22:18
  • If you want to track the HTTP request, you'd need to strace the HTTP server, but you don't have to because nginx's debug logging is excellent. I've updated my answer with some strace usage help. – womble Mar 31 '12 at 23:07
  • Aha! With strace I've found it's still trying to pull from the document root for some reason. Thanks! – Rob Mar 31 '12 at 23:55
2

Another way would be enable debug mode in error_log directive, see http://wiki.nginx.org/CoreModule#error_log

error_log error.log debug;

would produce more information on what happens inside nginx, but not fastcgi.

Some more info on http://wiki.nginx.org/Debugging also.

MaxDudu
  • 21
  • 2