Nginx PHP设置 - 未指定输入文件

时间:2017-10-20 07:56:26

标签: php ruby-on-rails wordpress nginx digital-ocean

我知道这是一个非常着名的问题。我已经尝试了几乎所有东西,但还没有解决。

意图是使用php / wordpress创建一个博客,已经存在nginx作为Web服务器。 Nginx已经被用作Rails应用程序的Web服务器。

这是我的nginx.conf看起来像

user  centos;
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    passenger_root /home/centos/.rvm/gems/ruby-2.1.4@tripshelf/gems/passenger-5.1.2;
    passenger_ruby /home/centos/.rvm/gems/ruby-2.1.4@tripshelf/wrappers/ruby;

    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    rails_env staging;

    server {
        listen       80;

        server_name  xx.xxx.xxx.xx;
        location / {
            root   /data/staging-tiger/current/public/;
            passenger_enabled on;
            index index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {
           root           /data/blog/;
           index          index.php index.html index.htm;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
           include        fastcgi_params;
        }
    }
}

我关注数字海洋的tutorial如何安装LEMP堆栈。

安装完成后,当我点击http://example.com/info.php时,我

 No input file specified 

在进一步的研究中,我试过:

  1. 将正确的权限设置为文档根目录 - / data / blog,并具有对/,/ data,/ data / blog和/data/blog/info.php

  2. 的正确执行权限
  3. php location block有自己的索引和根指令。

  4. Nginx以centos用户身份运行。这是ps aux | grep nginx

  5. 的输出

    root 11510 0.0 0.1 53984 1320 ? Ss 07:06 0:00 nginx: master process /opt/nginx/sbin/nginx

    centos 11513 0.0 0.2 54364 2612 ? S 07:06 0:00 nginx: worker process

    centos 13471 0.0 0.0 103312 876 pts/1 S+ 07:42 0:00 grep nginx

    1. 用户和群组在centos文件中设置为/etc/php-fpm.d/www.conf

      user = centos

      group = centos

    2. 在文档根目录上运行stat显示

    3. 文件:/data/blog/info.php

      Size: 20  Blocks: 8 IO Block: 4096   regular file
      Device: ca01h/51713d Inode: 525709   Links: 1
      Access: (0755/-rwxr-xr-x)  Uid: (  500/  centos)   Gid: (  500/  centos)
      Access: 2017-10-19 16:47:54.528000890 +0000
      Modify: 2017-10-19 16:47:54.528000890 +0000
      Change: 2017-10-20 06:18:28.000001084 +0000
      

      到目前为止,我一直在围绕着这个但是没有突破。请帮忙。

      提前致谢

1 个答案:

答案 0 :(得分:1)

后面的指南不适用于WordPress,因此nginx配置可能稍微偏离。

尝试修改PHP块,注意添加的fastcgi_param行。

location ~ \.php$ {
    root           /data/blog/;
    index          index.php index.html index.htm;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
    include        fastcgi_params;

    fastcgi_split_path_info       ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO       $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

如果失败,可能会有一些东西可以使用 https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/

或更详细 https://codex.wordpress.org/Nginx

此外,它应该在nginx日志文件中生成错误。

clear && tail -f /var/log/nginx/error.log