加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

nginx和php-fpm“主要脚本未知”

发布时间:2020-12-13 21:08:22 所属栏目:Nginx 来源:网络整理
导读:我知道,闻起来像是重复的,但我现在已经尝试了5次安装,但我仍然无法使用它.大多数配置很复杂的chroot和多服务器等,但我已经减少了现在最简单的配置可能.我想了解fpm是如何以最简单的形式设置nginx的请耐心等待. 当前设置: CentOS 7 64位 来自Nginx repo的ngi

我知道,闻起来像是重复的,但我现在已经尝试了5次安装,但我仍然无法使用它.大多数配置很复杂的chroot和多服务器等,但我已经减少了现在最简单的配置可能.我想了解fpm是如何以最简单的形式设置nginx的……请耐心等待.

当前设置:

> CentOS 7 64位
>来自Nginx repo的nginx 1.8.0
>来自Remi php56的php 5.6

添加到/etc/nginx/conf.d/default.conf

    location ~ .php${
      fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include        fastcgi_params;
    }

添加和更改/etc/php-fpm.d/www.conf

listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

添加了文件/usr/share/nginx/html/info.php

开始这两项服务

systemctl start nginx.service
systemctl start php-fpm.service

最后是tail -f /var/log/nginx/error.log

2015/11/09 12:18:01 [error] 28638#0: *1 FastCGI sent in stderr:
Primary script unknown” while reading response header from upstream,
client: xx.xxx.xxx.xxx,server: localhost,request: “GET /info.php
HTTP/1.1”,upstream: “fastcgi://unix:/var/run/php-fpm/php-fpm.sock:”,
host: “xxx.xx.xxx.xx”

所以似乎FPM找不到脚本,这是我设法理解的,但根据配置,脚本文件名是文档根和脚本名称.脚本名称为info.php,根据默认配置,根路径为:

    location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
}

因此,如果我手动连接,我得到

/usr/share/nginx/html/info.php

这个文件存在

#ls -lah /usr/share/nginx/html/
total 20K
drwxr-xr-x 2 root root  4.0K Nov  9 12:35 .
drwxr-xr-x 3 root root  4.0K Apr 21  2015 ..
-rw-r--r-- 1 root root   537 Apr 21  2015 50x.html
-rw-r--r-- 1 root root   612 Apr 21  2015 index.html
-rw-r--r-- 1 root nginx   20 Nov  9 10:45 info.php

任何人都可以解释为什么这不起作用?

最佳答案
$document_root需要从同一位置或父容器中的根指令中获取其值.您似乎在兄弟容器中定义了root.将root移动到服务器容器.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读