Include order and variables definition in configuration

Maxim Dounin mdounin at
Tue Feb 25 01:49:22 UTC 2014


On Tue, Feb 25, 2014 at 01:05:44AM +0100, B.R. wrote:

> Hello Francis and Maxim,
> I understand very well that $fastcgi_script_name value is defined after
> fastcgi_split_path_info is called.
> However I was wondering about other variables which value depend on
> $fastcgi_script_name, for example when PHP's SCRIPT_NAME has been defined
> in the already included fastcgi.conf.

There is no "variables which value depend on 
$fastcgi_script_name".  The fastcgi_param directive defines 
parameters to be sent to FastCGI application.

> Here are 2 examples:
> server {
>         listen               80;
>         server_name;
>         try_files            $uri $uri/ /index.php$uri;
>         root    /var/www;
>         index   index.html index.htm index.php;
>         include fastcgi.conf;
>         fastcgi_buffers 8 8k;
>         location ~ ^/index\.php {
>                 fastcgi_split_path_info ^(/index\.php)(/.*)$;
>                 fastcgi_param PATH_INFO $fastcgi_path_info;
>                 fastcgi_pass unix:/var/run/php5-fpm.sock;
>         }
> }
> The previous configuration seems to fail (returns 200 with blank page, no
> error).

The above configuration has only one fastcgi_param in 
"location ~ ^/index\.php".  And there are no parameters which 
include $fastcgi_script_name, so your previous question is 
completely irrelevant here.

Note (quote from

: These directives are inherited from the previous level if and only 
: if there are no fastcgi_param directives defined on the current 
: level.

There are fastcgi_param directives in "location ~ ^/index\.php", 
so fastcgi_params directives used on previous levels are not 

Maxim Dounin

More information about the nginx mailing list