nginx不执行php文件

nginx不执行php文件,php,nginx,Php,Nginx,我在这个帮助下安装了nginx 当我进入http://localhost/index.php它给了我一个空屏幕。这是我的默认设置: server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.html index.htm index.php index.nginx-debian.html; server_name localhost; location

我在这个帮助下安装了nginx 当我进入
http://localhost/index.php
它给了我一个空屏幕。这是我的默认设置:

server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;

index index.html index.htm index.php index.nginx-debian.html;

server_name localhost;

location / {
    try_files $uri $uri/ /index.html;
}

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            allow ::1;
            deny all;
    }

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
#   include snippets/fastcgi-php.conf;
#
#   # With php5-cgi alone:
    fastcgi_pass 127.0.0.1:9000;
#   # With php5-fpm:
#   fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}
}

有什么问题吗?

在php位置尝试以下方法:

location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

然后重新加载nginx和php-fpm(如果你得到一个坏网关是一个php-fpm错误(重新加载))

你在根目录(/var/www/html)中创建了index.php文件吗?不过我强烈推荐这本指南:是的,index.php是php位置的首选:
location~\.php${try\u files$uri=404;fastcgi\u split\u path\u info^(.+\.php)(/.+)$;fastcgi_pass unix:/var/run/php5-fpm.sock;fastcgi_index index.php;fastcgi_参数脚本文件名$document\u root$fastcgi_脚本名称;包含fastcgi_参数;}
然后重新加载nginx和php fpmFind out what's erred)在www.conf中是listen=127.0.0.1:9000。现在一切正常,非常感谢)