2017-08-19 66 views
0

我剛剛在Ubuntu 16.04上安裝了PHP 7.1-fpm的Nginx,我遇到了問題。當我想訪問例如http://example.dev它下載 index.php,而不是顯示主頁,但例如http://example.dev/registration運作良好。nginx和index.php正在下載

這是我的nginx的配置:

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

    root /var/www/example/www; 

    index index.php index.html; 

    server_name example.dev; 

    location/{ 
     try_files $uri $uri/ /index.php?$args; 
    } 

    location ~ /\. { 
     access_log off; 
     log_not_found off; 
     deny all; 
    } 

    location ~ \.php$ { 
     include snippets/fastcgi-php.conf; 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/run/php/php7.1-fpm.sock; 
     include fastcgi_params; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 
} 

謝謝您的回答。

+0

嘗試移動'位置/ { try_files $ URI $ URI//index.php?$args; }'到底 –

+0

你有沒有在php.ini文件中設置'cgi.fix_pathinfo'? –

+0

@TarunLalwani我試過了,但沒有幫助。 – fist

回答