【问题标题】:Nginx downloads php file in SOME cases (not all)Nginx 在某些情况下(不是全部)下载 php 文件
【发布时间】:2014-12-22 18:20:49
【问题描述】:

我遇到了 php5-fpm 和 nginx 的奇怪问题。

这是我的 nginx 配置:

server {
    listen   80;


    root /usr/share/nginx/www;
    index index.php index.html index.htm;

    server_name example.com;

    location / {
            try_files $uri $uri/ /index.html;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
          root /usr/share/nginx/www;
    }

    # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;

    }

}

所以我将 phpbb 论坛和 phpMyAdmin 下载到 /usr/share/nginx/www 每个都在自己的目录中。所以我有两个目录: /usr/share/nginx/www/phpMyAdmin 和 /usr/share/nginx/www/phpbb 当我尝试访问:http://example.com/phpMyAdmin 网络浏览器下载 phpMyAdmin 的 index.php,但是当我导航到:http://example.com/phpbb 它呈现整个论坛(它是用 php 编写的,因此它可以正确解析 php)。 以上配置只是我激活的一个。

重要提示:如果我导航到http://example.com/phpMyAdmin/index.php,它可以正常工作。

有什么建议吗?

我在配置我的 nginx 时遵循了该教程:https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-debian-7

【问题讨论】:

    标签: nginx php


    【解决方案1】:

    我发现这是浏览器问题,而不是服务器问题。当我清除浏览器中的缓存时,一切正常。

    【讨论】:

      猜你喜欢
      • 2016-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-03
      相关资源
      最近更新 更多