FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,

在对nginx添加fastCGI的支持后,然后进行php页面验证,发现页面识别不到,不清楚什么情况,随后google了下,原来是Nginx内置变量问题惹的祸。

1、平台介绍:


1

2

3

4

5

6

OS Version:        CentOS release 6.4 (Final)

Nginx Version:     nginx version: nginx/1.4.3

PHP Version:       PHP 5.5.5 (fpm-fcgi)

Mysql Version:     Server version: 5.6.10-log Source distribution

Kernel Version:    2.6.32-358.el6.x86_64

IP    address:     192.168.168.133


1

2、报错信息:


1

2013/10/22 20:05:49 [error] 12691#0: *6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.168.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.168.133"

3、错误原因及解决方法:

主配置文件第69行定义调用脚本文件路径:


1

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

而Nginx识别不到/scripts路径,所以phpinfo验证信息就无法正常通过,需要修改如下:


1

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Note:

$document_root 代表当前请求在root指令中指定的值。

我们这里为系统默认,


1

2

3

4

location / {

       root   /usr/local/nginx/html;

       index  index.php index.html index.htm;

        }

所以该语句就是针对/usr/local/nginx/html目录下的php文件进行解析。

然后再次进行页面查看已经ok.

参考文章:

原文地址:https://www.cnblogs.com/wanglijun/p/8777945.html

时间: 2024-08-29 08:36:48

FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,的相关文章

测试PHP是否安装成功时,nginx报错:"Primary script unknown"

小生博客:http://xsboke.blog.51cto.com 小生 Q Q:1770058260-------谢谢您的参考,如有疑问,欢迎交流 环境php-5.6.36nginx-1.14.0 问题访问php测试文件时报404(文件不存在),已经确认权限和配置都没有问题. 处理过程查看nginx错误日志:报如下错误(172.16.6.236是服务器) 2018/08/03 01:05:34 [error] 57141#0: *242 FastCGI sent in stderr: "Pri

PHP Primary script unknown 终极解决方法

相信很多配置php环境的都遇到过这个恼人的问题: 浏览器访问php文件,返回来 File not found 查看/var/log/nginx/error.log ,有 “Primary script unknown”,类似如下: 2019/01/03 10:24:02 [error] 11931#11931: *260 FastCGI sent in stderr: "Primary script unknown" while reading response header from

[PHP] 安装PHP报错“Primary script unknown”的解决方法

当安装完最新版的nginx和最新版的PHP以后,使用niginx默认配置文件中的PHP配置会有错误访问指定目录下的php文件时,显示File not found.错误.查看nginx的错误日志显示 90#90: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: 127.0.0.1, requ

nginx FastCGI错误Primary script unknown解决办法

解决方法: 修改 fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name; 为: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 上面配置中的$document_root就是针对root 目录下的php文件进行解析.

Nginx报Primary script unknown的错误解决

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 改成红色部分变量 root   /usr/local/nginx/html; 把root节点提前到location上面 原文地址:https://www.cnblogs.com/EasonJim/p/9615042.html

NGINX: Primary script unknown

参考: [ StackExchange ] 这里的解决方式应该是你排查了所有原因依然无法解决问题. SELINUX 更改 Selinux 配置 chcon -R -t httpd_sys_content_t path/to/webroot 或者干脆关闭 Selinux setenforce=0 sed -i "s/SELINUX=.*/SELINUX=disabled/1" /etc/selinux/config 原文地址:https://www.cnblogs.com/tiantia

FastCGI sent in stderr: "Unable to open primary script:index.php (Operation not permitted) 问题解决

出现这类问题时,需要检查一下nginx定位的网站根目录中,是否有user.ini 文件 至于user.ini 文件是什么 https://www.php.net/manual/zh/configuration.file.per-user.php#111834 中有介绍 这类文件仅会被cgi/fast cgi/sapi处理,次文件会使得pecl 的htscanner扩展作废,所以路径没填写正确会产生这样的异常.如果使用apache,则用.hataccess 有同样的效果 原文地址:https://

nginx服务器上遇到了acces denied,报错是fastCGI只要好好修改配置就行了

猜想: 懵逼 实践: 首先通用的方法,并没有解决问题. 1.修改php-fpm配置文件vim /etc/php-fpm.d/www.confuser = nginx        编辑用户为nginxgroup = nginx        修改组为nginx 2.修改目录权限chown nginx.nginx /usr/share/nginx/html/ -R #设置目录所有者chmod 700 /usr/share/nginx/html/ -R #设置目录权限 定位: 首先看报错: 2013

Nginx1.8.0 编译安装

1.准备安装包 下载最新稳定版nginx-1.8.0 http://nginx.org/en/download.html 2.安装环境准备          Centos 6.5(Final) yum-y install pcre-devel openssl-devel 3. 安装 (a) 解压然后编译 ./configure--prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx--group=nginx