Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't notice any difference if in my config file I set

 fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;


 fastcgi_param  SCRIPT_FILENAME    $request_filename;

What do they do respectively? Is one of the two better than the other?

Thanks in advance.

share|improve this question
up vote 12 down vote accepted

Here's what the documentation says:


This variable is equal to path to the file for the current request, formed from directives root or alias and URI request;


This variable is equal to the value of directive root for the current request;


This variable is equal to the URI request or, if if the URI concludes with a forward slash, then the URI request plus the name of the index file given by fastcgi_index. It is possible to use this variable in place of both SCRIPT_FILENAME and PATH_TRANSLATED, utilized, in particular, for determining the name of the script in PHP.

As written here, there's at least a difference when using *fastcgi_index* or *fastcgi_split_path_info*. Maybe there are more ... that's what I know of right now.


You get the request "/info/" and have the following configuration:

fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  /home/www/scripts/php$fastcgi_script_name;

SCRIPT_FILENAME would equal "/home/www/scripts/php/info/index.php", but using $request_filename it would just be "/home/www/scripts/php/info/".

When using it's important as well. See here for further help:

share|improve this answer

I guess those lines were taken from the 'fastcgi_params' file..

Basically you are not getting any errors when it comes to SCRIPT_FILENAME because it's already defined when you defined your root directive in your vhost file. So unless you defined it explicitly in your vhost file using fastcgi_param the value of SCRIPT_FILENAME would be taken from the root directive.. But ONE IMPORTANT POINT HERE. There is another variable that nginx needs in order to send the requests to the php server which is $fastcgi_script_name and you have to define it well in order to avoid repetitive URLs and errors with uri's that end with slash.


To make everything work super nice, everyone should define SCRIPT_FILENAME explicitly either in 'fastcgi_params' file located in /etc/nginx folder or easily in the vhost of your site located in sites-available folder by including the following line in the php location block:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

or included in the 'fastcgi_params' file as you wrote above, either way it's the same.. For more info for connecting ngnix to PHP-FPM go to:

I hope it would help anyone in the future 'cuz it took me a lot of time to figure it out..

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.