File Not Found when running PHP with Nginx File Not Found when running PHP with Nginx nginx nginx

File Not Found when running PHP with Nginx


Try another *fastcgi_param* something like

fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;


I had the "file not found" problem, so I moved the "root" definition up into the "server" bracket to provide a default value for all the locations. You can always override this by giving any location it's own root.

server {    root /usr/share/nginx/www;    location / {            #root /usr/share/nginx/www;    }    location ~ \.php$ {            try_files $uri =404;            fastcgi_split_path_info ^(.+\.php)(/.+)$;            fastcgi_pass 127.0.0.1:9000;            fastcgi_index index.php;            include fastcgi_params;    }}

Alternatively, I could have defined root in both my locations.


Probably it's too late to answer but a couple things since this is a really annoying error. Following solution worked on Mac OS X Yosemite.

  1. It's the best if you have

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  1. The include with fast cgi params should go above that line.

  2. All your directories down to the PHP file you're executing (including that file too) should have a+x permissions, e.g.

sudo chmod a+x /Users/sudo chmod a+x /Users/oleg/sudo chmod a+x /Users/oleg/www/sudo chmod a+x /Users/oleg/www/a.php