PHP-FPM/nginx-SELinux:未指定输入文件

PHP-FPM/nginx-SELinux:未指定输入文件

我在 Fedora 上设置 nginx(使用 Passenger,运行良好)和 php-fpm 时遇到问题。当我尝试通过浏览器访问 index.php 时,出现“未指定输入文件”提示。

Nginx 错误日志:

2013/11/29 12:50:47 [错误] 2218#0:*15 FastCGI 在 stderr 中发送:“无法打开主脚本:/home/nginx/html/phptest/index.php(没有此文件或目录)”,同时从上游读取响应标头,客户端:109.230.17.250,服务器:...,请求:“GET /index.php HTTP/1.1”,上游:“fastcgi://127.0.0.1:9000”,主机:“...”该文件存在。

PHP-FPM 错误日志未显示任何内容。

PHP-FPM 状态页面正常运行。Nginx 和 PHP-FPM 在用户 nginx 下运行。

Nginx 配置:

        server {
            listen 80;
            server_name ...;
            root /home/nginx/html/phptest;
            index index.php index.html index.htm;
            location ~ \.php$ {
                    include fastcgi.conf;
                    try_files $uri =404;
                    fastcgi_pass 127.0.0.1:9000;
            }
            location ~ ^/(status|ping)$ {
                 #access_log off;
                 include fastcgi.conf;
                 fastcgi_pass 127.0.0.1:9000;
            }
    }

PHP:doc_root 为空,open_basedir 未定义,cgi.fix_pathinfo=0 https://gist.github.com/anonymous/7705152

PHP-FPM www.conf:https://gist.github.com/anonymous/7705155

index.php 文件存在,并且可以由用户 nginx 本身以及其他用户访问。

我尝试了不同的 nginx 配置,但都无济于事。我猜想它与 fastcgi 周围的不同路径处理有关,但我不知道该怎么做。

感谢帮助。

更新:SELinux 导致了这个问题,现在我以宽容模式运行它。不确定如何创建正确的策略而不导致中断。

答案1

您可以尝试将您的服务器块更改为这样吗?

server {
    listen 80;
    server_name ...;
    root /home/nginx/html/phptest;
    index index.php index.html index.htm;
    location ~ \.php$ {
        root           /home/nginx/html/phptest;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

相关内容