2015-10-27 64 views
0

我在这个site 的帮助下安装nginx,当我升到http://localhost/index.php时,它给了我空白的屏幕。这是我的默认设置:nginx不执行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; 
} 
} 

它有什么问题?

+0

你创建的Nginx和PHP-FPM(如果你得到一个坏网关是一个php-fpm的错误(重装吧))你的根(/ var/www/html)一个index.php文件? – Naramsim

+0

是的, index.php有 – Torondor

回答

0

尝试一下本作的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; } 

然后重新