nginx 访问 .php文件变成下载(chrome) 或者直接显示源码(edge)

nginx 访问 .php文件变成下载(chrome) 或者直接显示源码(edge)

原因:这是因为nginx没有设置好碰到php文件时,要传递到后方的php解释器。

需要在nginx.conf的server{}添加如下内容:

    location ~ [^/]\.php(/|$) {
      #fastcgi_pass remote_php_ip:9000;
      fastcgi_pass unix:/dev/shm/php-cgi.sock;
      fastcgi_index index.php;
      include fastcgi.conf;
    }

版权

评论