“没有指定输入文件”nginx不解释php

时间:2014-02-17 18:15:47

标签: php nginx

我已经在PHP中替换了从apache到nginx的配置,这就是我的nginx配置看起来像

user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type text/html;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf;

}

此外,我的服务器配置如下所示

 server {
     listen 80;
     server_name  prod.my-domain.com;
     root   /usr/share/nginx/html/prod.my-domain.com;

     location / {
           root /usr/share/nginx/html/prod.my-domain.com;
     }

   location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /root/share/nginx/html/prod.my-domain.com$fastcgi_script_name;
    }
   }

显示所有HTML文件/图像,但php文件,即使其index.php显示

  

未指定输入文件

我有错误报告。我不知道问题是什么

修改

好的,我将服务器配置更改为以下

 server {
     listen 80;
     server_name  demo.simons.co.de;
     root   /usr/share/nginx/html/prod.my-domain.com;

     location / {
           root /usr/share/nginx/html/prod.my-domain.com;
          index index.php index.html index.htm;
     }

   location ~.\.php$ {
      #  include /etc/nginx/fastcgi_params;
      # fastcgi_pass   unix:/var/run/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /root/share/nginx/htmli/$document_root$fastcgi_script_name;
    }
   }

现在,当我访问此网址prod.my-domain.com/index.php时,我只看到黑页 但prod.my-domain.com/index.html我可以看到所有内容

1 个答案:

答案 0 :(得分:0)

fastcgi_pass 127.0.0.1:9000;

你确定有人在那里听吗?

配置nginx是不够的。 您还需要fastcgi broker来管理fastcgi实例。 例如 - 来自lighttpd包的php-fpm或spawn-fcgi。

如果是 - 请检查该代理是否具有/ root / share / nginx / html ....的文件访问权限。