在许多站点上都可以找到这个 nginx location
堵塞 :
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000
fastcgi_index index.php
...
}
鉴于 official documentation的
fastcgi_index
, 好像是在请求以 /
结束时使用.但是,它与 location
的正则表达式不匹配。挡在上面?我是否遗漏了有关 fastcgi_index
的一些信息?指示?
最佳答案
你是对的,如果你的 nginx 配置(在 location
指令之外)没有 index
指令,然后是 location
指令永远不会匹配并且 fastcgi_index
指令没用。
如果您的配置中有这样的一行
index index.php
然后向
/
发出请求将创建一个内部重定向到 /index.php
, location
将匹配并调用 fastcgi。 php-fpm 需要一个 SCRIPT_FILENAME
指向正在执行的文件的参数。通常,配置如下所示:fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
$fastcgi_script_name
包含匹配脚本的名称,所以 fastcgi_index
被忽略。至少有一个实例是
fastcgi_index
有用和使用:when nginx and php-fpm are on different servers and nginx can't match the index.php file .
关于nginx - nginx 中的 fastcgi_index 是干什么用的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30802025/