【问题标题】:Nginx write "no input file specified" after root directory change - CentOS 7Nginx在根目录更改后写入“未指定输入文件” - CentOS 7
【发布时间】:2016-06-22 18:43:09
【问题描述】:

我对 Linux 系统缺乏经验,现在正在尝试配置 Nginx + Nodejs 服务器。首先尝试使其工作并为 phpMyAdmin 配置 fast-cgi php。当我使用默认的“/usr/share/nginx/html”目录时。一切正常,但是当我将根目录更改为“/home/ftpuser/web/public”时,浏览器中出现“未指定输入文件”错误。但是我的测试页面是一个简单的 html...

我的 nginx 配置文件如下:

server {

      listen  80 default_server;

  server_name _;

      #root /home/ftpuser/web/public;
      root /usr/share/nginx/html;
      index index.html index.htm index.php;

      location / {

        try_files maintenance.html $uri $uri/index.html $uri/index.php;

      }

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

      location @node {
    error_page 405 = @backend;
        add_header X-Cache "HIT from Backend";
        proxy_pass http://212.24.106.170:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        #proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
      }
}

我不知道出了什么问题。我只是猜测可能是权限问题?有谁知道问题出在哪里?

更新:

基于 nginx error.log,这是一个漂亮的权限问题:

[crit] 32338#0: *1 stat() "/home/ftpuser/badgirlz/public//index.html" failed (13: Permission denied), client: 78.92.44.152, server: _, request: "GET / HTTP/1.1", host: "domain.com"

我做了以下:

chown -R nginx:nginx /home/ftpuser/web/public
chmod -R 755 /home/ftpuser/web/public

但是还是没有解决问题...

【问题讨论】:

  • 你看过例如。 NGINX - No input file specified. - php Fast/CGI 已经或其他 SO Q&A 页面弹出,当一个“搜索”说“nginx 没有指定输入文件”;-)?
  • 它不起作用,无论如何,正如我所写,我在另一个目录中有简单的 html 文件,所以即使有 php 问题,它也应该适用于简单的 html 页面,但我收到了上面的消息.这就是奇怪的事情......
  • ... 好吧,也许然后:Nginx 403 forbidden for all files ... 否则我建议在文件夹上使用 stat/ls -l ,并检查 nginx 日志 ...也许更新问题。 .. HTH
  • 似乎 nginx 无法读取该文件,因此它默认为 $uri/index.php 也无法被 php-fpm 读取。这可能是 SELinux 问题吗?
  • 我不这么认为。当我输入“getenforce”时,它会返回“禁用”。因此,如果我是正确的,SELinux 将被禁用。

标签: php linux nginx centos7


【解决方案1】:

查看您的日志:

[crit] 32338#0: *1 stat() "/home/ftpuser/badgirlz/public//index.html" 失败(13:权限被拒绝),

chown -R nginx:nginx /home/ftpuser/web/public chmod -R 755 /home/ftpuser/web/public

我认为您正在更改错误文件夹的权限。 试试:

chown -R nginx:nginx /home/ftpuser/
chmod -R 755 /home/ftpuser/

查看here 了解有关 Linux 上文件权限的更多信息,它可能会对您有所帮助。

【讨论】:

    猜你喜欢
    • 2019-11-17
    • 1970-01-01
    • 1970-01-01
    • 2012-09-02
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多