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

不言
Release: 2023-04-02 16:20:01
Original
4179 people have browsed it

这篇文章主要介绍了关于对于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;
    }
Copy after login

后来修改为如下:

    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;
    }
Copy after login

唯一的区别是:

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

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!