Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
See this question 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 1: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 1:46

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
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

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.