Home >Backend Development >PHP Tutorial >Solution to the configuration error of fastcgi_param in the nginx configuration file

Solution to the configuration error of fastcgi_param in the nginx configuration file

不言
不言Original
2018-07-06 10:17:184235browse

这篇文章主要介绍了关于对于nginx配置文件中的fastcgi_param的配置错误的解决,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

在centos中搭建LNMP的时候,遇到了一个问题 在浏览器中访问.php文件的时候,nginx不能正常解析,页面返回404,后来百度了一下,发现了问题

在nginx的配置文件nginx.conf中的server配置段:

一开始如下:

    location ~ /admin/qzh/.+\.php$ {
               if ($fastcgi_script_name ~ /admin/qzh/(.+\.php.*)$) {
                        set $valid_fastcgi_script_name $1;
                }
                fastcgi_pass 127.0.0.1:1026;
                fastcgi_param  SCRIPT_FILENAME  /home/web/admin/web/$valid_fastcgi_script_name;
                include  fastcgi_params;
    }

后来修改为如下:

    location ~ /admin/qzh/.+\.php$ {
               if ($fastcgi_script_name ~ /admin/qzh/(.+\.php.*)$) {
                        set $valid_fastcgi_script_name $1;
                }
                fastcgi_pass 127.0.0.1:1026;
		include  fastcgi_params;
                fastcgi_param  SCRIPT_FILENAME  /home/web/admin/web/$valid_fastcgi_script_name;
    }

唯一的区别是:

include  fastcgi_params; 位置进行了调整就可以了。
刚开始大家都忽略了加载顺序的问题,搞了好长时间。

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!

相关推荐:

nginx memcache缓存的介绍

PHPstorm配置PHPunit对composer引入的php代码进行单元测试

The above is the detailed content of Solution to the configuration error of fastcgi_param in the nginx configuration file. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn