2015-10-27 112 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; } 

然後重新