Recently I installed the latest version of Nginx and looks like I'm having hard time running PHP with it.
Here is the configuration file I'm using for the domain:
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}
Here is the error I'm getting on the error log file:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
When getting "File not found", my problem was that there was no symlink in the folder where was pointing this line in ngix config:
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.
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.I had this error as well. In my case it was because there was another virtual host that was pointing to the same root directory.
In my case, it was because the permissions on the root web directory were not set correctly. To do this, you need to be in the parent folder when you run this in terminal:
This will chmod all files in your html folder, which is not recommended for production for security reasons, but should let you see the files in that folder, to be sure that isn't the issue while troubleshooting.
I just spent like 40 minutes trying to debug a non-working /status with:
It just produced "File not found" error, while the actual scripts (that are found on the filesystem) worked just fine.
Turned out, I had a couple of orphaned processes of php5-fpm. After I killed everything and restarted php5-fpm cleanly, it just went back to normal.
Hope this helps.
After upgrading to PHP72, we had an issue where the php-fpm.d/www.conf lost the settings for user/group which was causing this error. Be sure to double check those if your setup involves php-fpm.