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)

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

报告相同问题?

悬赏问题

  • ¥15 系统 24h2 专业工作站版,浏览文件夹的图库,视频,图片之类的怎样删除?
  • ¥15 怎么把512还原为520格式
  • ¥15 MATLAB的动态模态分解出现错误,以CFX非定常模拟结果为快照
  • ¥15 求高通平台Softsim调试经验
  • ¥15 canal如何实现将mysql多张表(月表)采集入库到目标表中(一张表)?
  • ¥15 wpf ScrollViewer实现冻结左侧宽度w范围内的视图
  • ¥15 栅极驱动低侧烧毁MOSFET
  • ¥30 写segy数据时出错3
  • ¥100 linux下qt运行QCefView demo报错
  • ¥50 F1C100S下的红外解码IR_RX驱动问题