4

when i have something this:

location ~ .php$ { ## Execute PHP scripts
    if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss

    expires        off; ## Do not cache dynamic content
    include        fastcgi_params; ## See /etc/nginx/fastcgi_params
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param  ID_DEVELOPER_MODE 1;
}

is it important where to put the include directive? because the file /etc/nginx/fastcgi_params already has a SCRIPT_FILENAME declaration inside.

1 Answer 1

4

The fastcgi_param directive is documented here. And although it is clear regarding inheritance it is not clear regarding the setting of the same parameter more than once (at the same level).

By experiment, it seems that nginx silently overwrites a previous value at the same level.

So the answer to your question is to place the include directive before any fastcgi_param directives that take priority.

2
  • The documentation itself contains many examples where it includes it after some fastcgi_params -- See nginx.com/resources/wiki/start/topics/examples/phpfcgi -- Is the documentation misleading somehow?
    – jweyrich
    Dec 10, 2018 at 14:04
  • @jweyrich Indeed it is. If the parameter you are setting is guaranteed not to be in the file (such as in the link you cite), you can arrange the statements in either order . But the contents of fastcgi_params varies across different distributions, so if I am answering a question where I need to set a parameter, I sometimes emphasize that the order may be significant. Dec 10, 2018 at 14:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .