报错:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
安装完nginx和php-fpm访问php文件的时候提示"File not found.",
错误解决方法:
在Nginx配置文件中找到定义调用脚本文件的地方,如:
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
修改成如下方式($document_root):
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
提示:$document_root 代表当前请求在root指令中指定的值。如:
location / {
root /usr/local/nginx/html;
index index.php index.html index.htm;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
上面配置中的$document_root就是针对/usr/local/nginx/html目录下的php文件进行解析。