douzhanlai4671 2017-08-19 16:08
浏览 54
已采纳

nginx和index.php下载

I just installed Nginx with PHP 7.1-fpm on Ubuntu 16.04 and I have a problem. 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.

This is my nginx config:

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.

  • 写回答

1条回答 默认 最新

  • dpca31461 2017-08-19 18:20
    关注

    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 <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd> in your browser.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan