Niche Blog: http://xsboke.blog.51cto.com
Niche Q q:1770058260
-------Thank you for your reference, if you have any questions, please contact
- Environment
php-5.6.36
nginx-1.14.0
- Problem
Access PHP test file times 404 (file does not exist), has confirmed that the permissions and configuration are not a problem.
- Processing process
View Nginx error log: reported the following error (172.16.6.236 is the server)2018/08/03 01:05:34 [error] 57141#0: *242 FastCGI sent in stderr: "Primary script unknown" while readingresponse header from upstream, client: 172.16.6.237, server: localhost, request: "GET /test.php HTTP/1.1",upstream: "fastcgi://127.0.0.1:9000", host: "172.16.6.236"
- Resolution process
In the Nginx official website to see if there are similar errors, found no, and then Baidu .... (Laugh and Cry)
The solution is as follows,
Will:#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
Modified to:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
Explain:$document_root 就是nginx配置项“root”指定的位置参数的变量
To test if PHP was installed successfully, Nginx error: "Primary script Unknown"