nginx+php-fpm 报错Primary script unknown
报错信息(nginx日志):
// :: [crit] #: * stat() "/home/xiaoju/webroot/c-api-intl/app/htdocs/user/getUserInfo" failed (: Permission denied), client: 172.21.205.25, server: localhost, request: "GET /user/getUserInfo HTTP/1.1", host: "10.96.83.130:8005"
// :: [crit] #: * stat() "/home/xiaoju/webroot/c-api-intl/app/htdocs/user/getUserInfo" failed (: Permission denied), client: 172.21.205.25, server: localhost, request: "GET /user/getUserInfo HTTP/1.1", host: "10.96.83.130:8005"
// :: [error] #: * FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.21.205.25, server: localhost, request: "GET /user/getUserInfo HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "10.96.83.130:8005"
意思就是找不到php的入口脚本,那么查看nginx配置是否有问题,主要关注以下配置中标红的部分:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param ENV_CAPI_DEBUG true;
fastcgi_param APP_ENV development;
include fastcgi_params;
}
我们也可以加nginx日志来验证 SCRIPT_FILENAME 是否配置正确:
# add to nginx.conf
log_format scripts '$document_root$fastcgi_script_name > $request'; # add to server conf block
access_log /var/log/nginx/scripts.log scripts;
做好以上配置之后重启nginx并请求,同时tail -f /var/log/nginx/scripts.log,查看输出的php脚本能不能找到。
我这里输出是这样的:
/home/xiaoju/webroot/c-api-intl/app/htdocs/index.php > GET /user/getUserInfo HTTP/1.1
如果找不到该文件,重新配置nginx,保证php入口脚本能被找到。
如果已经找到该文件,而且还报此错误,那就是权限问题了:运行php-fpm的linux用户没权限访问php入口文件的权限。
我这里运行php-fpm的用户是nginx。(在/usr/local/php/etc/php-fpm.conf配置文件中配置的)
sudo -u nginx stat /home/xiaoju/webroot/c-api-intl/app/htdocs/index.php
果然权限不足,解决办法:
chown nginx:nginx /home/xiaoju/webroot/c-api-intl
chmod g+x /home
chmod g+x /home/xiaoju
chmod g+x /home/xiaoju/webroot
问题解决。
如果中途出现:account is currently not available
vipw /etc/passwd
把对应用户的/sbin/nologin 改成 /bin/bash。
参考文档:
https://www.jianshu.com/p/ce968818497b
https://www.e-learn.cn/content/wangluowenzhang/299721
https://blog.csdn.net/shaobingj126/article/details/7466583
nginx+php-fpm 报错Primary script unknown的更多相关文章
- [PHP] 安装PHP报错“Primary script unknown”的解决方法
当安装完最新版的nginx和最新版的PHP以后,使用niginx默认配置文件中的PHP配置会有错误访问指定目录下的php文件时,显示File not found.错误.查看nginx的错误日志显示 9 ...
- 解决nginx FastCGI sent in stderr: “Primary script unknown”
今天重启了mac,突然发现本地的 lnmp 服务不能用了,什么请求都返回了: FastCGI sent in stderr: "Primary script unknown" 这个 ...
- PHP Primary script unknown 终极解决方法
相信很多配置php环境的都遇到过这个恼人的问题: 浏览器访问php文件,返回来 File not found 查看/var/log/nginx/error.log ,有 “Primary script ...
- Nginx-Primary script unknown的报错的解决方法
配置nginx时一直报错:file not found 错误日志: [error] 12691#0: *6 FastCGI sent in stderr: "Primary script u ...
- Nginx+PHP配置错误,日志:[error] 24324#0: *31 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
一.问题现象 1.安装nginx.php.php-fpm后,浏览器访问php报错,“File not found”: 二.问题排查 1.检查nginx.php-fpm服务是否正常启动,均正常启动: 2 ...
- nginx FastCGI错误Primary script unknown解决办法
在centos上成功编译安装nginx 1.4.php 5.4并成功启动nginx和php-fpm后,访问php提示"File not found.",同时在错误日志中看到: 复制 ...
- Nginx配置SSL报错 nginx: [emerg] unknown directive "ssl"
Nginx配置SSL报错 nginx: [emerg] unknown directive "ssl" 出现如图所示错误,处理办法如下 去nginx解压目录下执行 ./co ...
- 【nginx】 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
2013/10/22 20:05:49 [error] 12691#0: *6 FastCGI sent in stderr: "Primary script unknown" w ...
- NGINX+PHP-FPM7 FastCGI sent in stderr: “Primary script unknown”
https://www.cnblogs.com/hjqjk/p/5651275.html 一开始是Nginx打开网页显示一直是拒绝访问.查看nginx日志是报错显示我的题目,然后就各种搜索解决啊! 百 ...
随机推荐
- SQL性能分析
MySQL常见瓶颈: CPU:CPU在饱和的时候一般发生在数据装入内存或从磁盘上读取数据的时候. IO:磁盘I/O瓶颈发生在装入数据远大于内存容量的时候. 服务器硬件的性能瓶颈:top.free.io ...
- 【数据结构】bzoj1636/bzoj1699排队
Description 每天,农夫 John 的N(1 <= N <= 50,000)头牛总是按同一序列排队. 有一天, John 决定让一些牛们玩一场飞盘比赛. 他准备找一群在对列中为置 ...
- 【poj1226-出现或反转后出现在每个串的最长公共子串】后缀数组
题意:求n个串的最长公共子串,子串出现在一个串中可以是它的反转串出现.总长<=10^4. 题解: 对于每个串,把反转串也连进去.二分长度,分组,判断每个组. #include<cstdio ...
- bzoj 2435 BFS
我们可以先将无根树变成有根树,随便选一个点当根就行了,我们选1,bfs求出来每个点 的size值,代表以它为根节点的子树中有多少个节点,(dfs可能会爆栈),然后再对于每一条 边算就好了 我tle了, ...
- 关于chkrootkit 检查 INFECTED: Possible Malicious Linux.Xor.DDoS installed
chkrootkit检测时,发现一个Xor.DDoS内容,内容如下...Searching for Linux.Xor.DDoS ... INFECTED: Possible Malicious Li ...
- python批量下载淘宝图片3
import urllib.request import os def url_open(url): req = urllib.request.Request(url) req.add_header( ...
- docker从零开始网络(三) overly(覆盖)网络
使用overly网络 该overlay网络驱动程序会创建多个docker进程主机之间的分布式网络.该网络位于(覆盖)特定于主机的网络之上,允许连接到它的容器(包括群集服务容器)安全地进行通信.Dock ...
- 以前在win7上死活安装不上的pymssql,现在可以安装了
作SQL发布时,支持了mssql,在linux上,pymssql安装一直没问题,但在windows7上就不可以. 今天要用了,心血来潮,下载了一个新的pymssql的exe文件, 就安装成功了... ...
- Android 网络url设置View背景图
imgstr为url网络图片地址,topllay是要设置背景的控件: 方法1.Android Glide设置View背景图 Glide.with(this).load(imgStr).asBitmap ...
- 针对“永恒之蓝”攻击紧急处置手册(蠕虫 WannaCry)
首先确认主机是否被感染 被感染的机器屏幕会显示如下的告知付赎金的界面: 如果主机已被感染: 则将该主机隔离或断网(拔网线).若客户存在该主机备份,则启动备份恢复程序. 如果主机未被感染: 则存在四种方 ...