今天重启了mac,突然发现本地的 lnmp 服务不能用了,什么请求都返回了:

FastCGI sent in stderr: “Primary script unknown”

这个就很尴尬了,可是我啥也没动啊,但是没有办法,出问题了就得查,google了一下,出这个问题一般有两个原因:

  • 一是nginx的配置文件问题

    即 /usr/local/etc/nginx/nginx.conf (个人的,你们的路径不一定是这个)中的 fastcgi_param 参数配置问题,nginx默认配置为:

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

  但是,如果你在nginx.conf 中设置了设置你本地的 root 目录(服务根目录),例如:

 root           /var/www/console/frontend/www/;

  那么需要将 fastcgi_param 参数修改为:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  配置完成后,尝试重启 nginx 和 php-fpm, 看下服务是否恢复了,如果没有恢复,请接着往下看:

  • 第二个原因是:php-fpm.conf 中设置了错误的用户和组别

  默认的php-fpm.conf 中会 include 这个一个文件夹(可能会不同):

include=/usr/local/etc/php/7.1/php-fpm.d/*.conf

   意思是把 php-fpm.d 文件夹下面的所有 .conf 结尾的文件都 include 进来,一般情况下,会在这些 .conf 文件中配置 user/group

  进行到这里,你可以执行一下下面这条命令,看下你目前的 php-fpm 是用什么身份运行的:

ps aux | grep -v root | grep php-fpm | cut -d\  -f1 | sort | uniq

  特别的,在OS X 系统下,用户应该是  :

user = [your username]
group = staff

  如果发现用户不对,比如,你的身份是 admin ,但是上面命令的执行结果却是 nobody,那么你需要将 php-fpm.d 文件夹(或者其他文件夹,或者直接在 php-fpm.conf 中进行设置,视个人情况而定)下的 user 修改为你当前的身份,同样的,修改完成后重启 nginx 和 php-fpm 看下是否正常

如果还是不正常,那么请参考下其他的解决方案,不过大部分情况,上面两种case 应该都包含进去了。

解决nginx FastCGI sent in stderr: “Primary script unknown”的更多相关文章

  1. 【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 ...

  2. 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 ...

  3. 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 ...

  4. [error] 1507#0: *22 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.0.0.1, server: www.wordpress.com, request: "GET /info.p

    字体比较小,如果你遇到这个问题请仔细的把下面的总结看完. 环境:CentOS6.7.2.6.32-573.el6.x86_64.nginx1.12.2 .php5.5.38 问题:nginx能解析静态 ...

  5. NGINX+PHP-FPM7 FastCGI sent in stderr: “Primary script unknown”

    https://www.cnblogs.com/hjqjk/p/5651275.html 一开始是Nginx打开网页显示一直是拒绝访问.查看nginx日志是报错显示我的题目,然后就各种搜索解决啊! 百 ...

  6. nginx FastCGI错误Primary script unknown解决办法

    在centos上成功编译安装nginx 1.4.php 5.4并成功启动nginx和php-fpm后,访问php提示"File not found.",同时在错误日志中看到: 复制 ...

  7. Nginx-Primary script unknown的报错的解决方法

    配置nginx时一直报错:file not found 错误日志: [error] 12691#0: *6 FastCGI sent in stderr: "Primary script u ...

  8. nginx+php-fpm 报错Primary script unknown

    报错信息(nginx日志): // :: [crit] #: * stat() : Permission denied), client: 172.21.205.25, server: localho ...

  9. PHP Primary script unknown 终极解决方法

    相信很多配置php环境的都遇到过这个恼人的问题: 浏览器访问php文件,返回来 File not found 查看/var/log/nginx/error.log ,有 “Primary script ...

随机推荐

  1. github、gitlab 管理多个ssh key

    第一种方法: 通过 git 命令行来操作 1.cd ~/.ssh 2.ls 注:如果.ssh 目录下有文件存在那么表示之前添加过 3. ssh-keygen -t rsa -C "xxxxx ...

  2. 调皮的QQ音乐API:修复无法获取歌单

    上一篇完整版:http://www.cnblogs.com/TwilightLemon/p/7076938.html QQ音乐的API真是太调皮了,获取歌单的API又更换了好多次,喵喵喵 旧版API( ...

  3. 华为服务器Linux在线做RAID方法

    背景概述 最近维护大数据的一些主机,大概有3k+的数目,有很大一部分是华为的服务器,大部分是12块数据盘,单盘做RAID0来存放数据,但是通常硬件是不可靠的,磁盘损坏是常态, 然而磁盘损坏进行定位更换 ...

  4. Hadoop新生报到(一) hadoop2.6.0伪分布式配置详解

    首先先不看理论,搭建起环境之后再看: 搭建伪分布式是为了模拟环境,调试方便. 电脑是win10,用的虚拟机VMware Workstation 12 Pro,跑的Linux系统是centos6.5 , ...

  5. Linux Shell 1 - Print from terminal

    Two ways to print info from terminal - echo & printf - Echo a. Exclamation mark is supported in ...

  6. JS存取Cookies值,附自己写的获取cookies的一个方法

    参考:脚本之家 这里对cookie进行了说明,也介绍了几个方法,但是我要取我存的cookie时取不到,他的方法只是针对存的  名字-值,不涉及键,所以自己写了个方法,来满足我的需求. ①你首先的了解C ...

  7. knockoutjs模板实现树形结构列表

    数据结构 /*数据*/ var ko_vue_data=[ { name: "总能耗", number:"0", energyone: 14410, energ ...

  8. 【模板--完全背包】HDU--2602 Bone Collector

    Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bone C ...

  9. 弱校ACM奋斗史

    看到这篇文章, 已是大三了, 我的ACM之路也即将走向终点, 感慨自己还是不够努力, 给自己的大学留下诸多遗憾. 和他们相比, 我差的就是太远了, 值得高兴的是我们学校有一个好老师-----赵靖老师, ...

  10. SqQueue(环状队列(顺序表结构))

    template<typename ElemType> class SqQueue { protected: int count; int front,rear; int maxSize; ...