File Not Found when running PHP with Nginx
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.
- It's the best if you have
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
The include with fast cgi params should go above that line.
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