今天在配置nginx的vhost的时候,需要在nginx动态的修改php的“auto_prepend_file”配置,所有就通过fastcgi_param PHP_ADMIN_VALUE path; 配置好以后刷新页面,空白了,经过debug和看文档,终于发现了原来nginx的fastcgi_param配置并不会继承上一级的配置,而是忽略所有上级配置,也就是说我在server配置的include fastcgi.conf在location里用fastcgi_param的话就会全部忽略fastcgi.conf内容,导致nginx没有把环境变量传到php-fpm,所以只需要在location里再引入一次fastcgi.conf就行了!


下面是fastcgi_param的文档,注意红色字体:

Sets a parameter that should be passed to the FastCGI server. The value can contain text, variables, and their combination. These directives are inherited from the previous level if and only if there are nofastcgi_param directives defined on the current level.


这句话的意思就是这些指令会继承上级配置,当且仅当fastcgi_param指令没有在当前层级定义,反过来就是当前层级如果定义了fastcgi_param,不管定义多少个都会全部忽略上级配置。