大网数据广告活动
服务器运维问答

nginx include fastcgi_params order

· 52CE 我爱测

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…

问题原文

原帖链接 · Kevin Horst · CC BY-SA 3.0

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.

社区高分解答

原帖链接 · Richard Smith · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-12-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。