linux nginx php-fpm出现解析执行php,不能访问php ,出现下载php文件

由于之前没有接触过nginx ,因此查了一天,查处缘由有二:php

1、网站根目录html

默认是在 /usr/local/nginx/html文件nginx

配置在网站

location  / {
            root  /home/www/wwwroot;
            index  index.html index.htm;
        }htm

2、修改文件中对应的php配置部分ip

   location ~ \.php$ {
            root          /home/www/wwwroot;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
           fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

特别须要注意的是:fastcgi_param这个参数默认的是$fastcgi_script_name;最好改成$document_root$fastcgi_script_name;我在实际配置中出现了php找不到须要解析文件而返回404或者500错误的问题。因此最好是带上网站根目录的路径变量$document_rootio

相关文章
相关标签/搜索