简体   繁体   English

nginx和index.php下载

[英]nginx and index.php downloading

I just installed Nginx with PHP 7.1-fpm on Ubuntu 16.04 and I have a problem. 我刚刚在Ubuntu 16.04上用PHP 7.1-fpm安装了Nginx,但遇到了问题。 When I wan to visit for example http://example.dev it downloads index.php instead of showing homepage, but for example http://example.dev/registration works well. 当我想访问例如http://example.dev时,它下载的是index.php而不是显示主页,但是例如http://example.dev/registration效果很好。

This is my nginx config: 这是我的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;
    }
}

Thanks for your answers. 感谢您的回答。

Sometimes it can be as simple as clearing the browser cache. 有时,就像清除浏览器缓存一样简单。 If there was some misconfiguration and it was indeed downloading files, after fixing the config the browser needs to be told to stop using the cached download. 如果配置错误,并且确实在下载文件,则在修复配置后,需要告知浏览器停止使用缓存的下载。

Try Ctrl + Shift + R in your browser. 在浏览器中尝试按Ctrl + Shift + R

(From: https://askubuntu.com/questions/460710/why-is-the-index-php-downloaded-instead-of-rendered-by-nginx ) (摘自: 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