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 just installed nginx 1.1.13 and php 5.4.0 on a centos 5.8 final 64bit machine. Nginx and PHP/Fpm are running, and I can run php scripts via ssh command line, but in the browser I keep getting 'File not found.' errors on all my PHP files.

This is how I have my nginx.conf handle PHP scripts:

      location ~ \.php$
      {
              root                    /opt/nginx/html;
              fastcgi_pass            unix:/tmp/fpm.sock;
              fastcgi_index           index.php;
              fastcgi_param           SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;
              include                 fastcgi_params;
      }

This is a direct copy/paste from my other servers, where it works fine with this setup (but they run older versions of php/fpm).

Why am I getting those errors?

share|improve this question
1  
Never mind, it's sorted. It was a silly permissions issue. –  Mr.Boon Mar 11 '12 at 12:44
add comment

3 Answers 3

up vote 11 down vote accepted

Put "include fastcgi_params;" before all "fastcgi_param *" lines, "include fastcgi_params;" overrides all you "fastcgi_param *" lines (see nginx debug log):

location ~ \.php$
{
    root                    /opt/nginx/html;
    fastcgi_pass            unix:/tmp/fpm.sock;
    fastcgi_index           index.php;
    include                 fastcgi_params;
    fastcgi_param           SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;
}
share|improve this answer
    
Man, I've wasted 4 hours on it and your answer helped me. –  ruslan Oct 21 '12 at 8:03
    
I have tried to overcome this problem since yesterday. Your answer helped me very much! Thank you!!! –  Kacper Kołodziej May 2 at 13:44
add comment

Never mind, it's sorted. It was a silly permissions issue

share|improve this answer
    
Glad you resolved the issue. Please mark your answer as "accepted" when you are able. –  jscott Jul 17 '12 at 23:56
4  
how did you got it solved? –  Eduardo Mello Oct 28 '12 at 18:40
add comment

I had the same issue, and for me it was a misconfigure/non-existing "root" directive in the nginx server config

share|improve this answer
add comment

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.