【问题标题】:Nginx PHP setup - No input file specifiedNginx PHP 设置 - 未指定输入文件
【发布时间】:2017-10-20 07:56:26
【问题描述】:

我知道这是一个众所周知的问题。我几乎尝试了所有方法,但仍然无法修复。

意图是使用 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. php 位置块有自己的索引和根指令。

  3. Nginx 以 centos 用户身份运行。这是ps aux | grep nginx的输出

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. 用户和组在/etc/php-fpm.d/www.conf 文件中设置为centos

    user = centos

    group = centos

  2. 文档根目录上的运行统计显示

文件:/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

我一直在思考这个问题,但到目前为止还没有突破。请帮忙。

提前致谢

【问题讨论】:

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


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-21
      • 1970-01-01
      • 1970-01-01
      • 2014-12-12
      • 1970-01-01
      • 2020-03-09
      • 2021-05-17
      • 1970-01-01
      相关资源
      最近更新 更多