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?

2
  • 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). Commented Mar 31, 2012 at 1:11
  • @cyberx86 I'll look at that, thanks. It's a location block used by many vhosts as you said. Commented Mar 31, 2012 at 1:46

2 Answers 2

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.

4
  • 1
    How could I use strace to track the HTTP request? Commented Mar 31, 2012 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. Commented Mar 31, 2012 at 23:07
  • Aha! With strace I've found it's still trying to pull from the document root for some reason. Thanks! Commented Mar 31, 2012 at 23:55
  • If you have no Idea what strace is (as I was), It's worth learning it Commented Aug 10, 2024 at 15:32
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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.