簡體   English   中英

nginx和index.php下載

[英]nginx and index.php downloading

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

這是我的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;
    }
}

感謝您的回答。

有時,就像清除瀏覽器緩存一樣簡單。 如果配置錯誤,並且確實在下載文件,則在修復配置后,需要告知瀏覽器停止使用緩存的下載。

在瀏覽器中嘗試按Ctrl + Shift + R

(摘自: https : //askubuntu.com/questions/460710/why-is-the-index-php-downloaded-instead-of-rendered-by-nginx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM