Nginx/FPM/PHP all php files say ‘File not found.’

nginxPHPphp-fpm

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?

Best Answer

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;
}