为什么有了 fastcgi_params 还要有 fastcgi.conf
fastcgi.conf
对比下fastcgi.conf与fastcgi_params文件,可以看出只有以下差异:
tctq4master@ddd:/etc/nginx$ diff fastcgi.conf fastcgi_params 2d1 < fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 25a25,26 > > fastcgi_param SCRIPT_FILENAME $request_filename;
即fastcgi.conf只比fastcgi_params多了一行
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
原本只有fastcgi_params文件,fastcgi.conf是nginx 0.8.30 (released: 15th of December 2009)才引入的。主要为是解决以下问题(参考:http://www.dwz.cn/x3GIJ):
原本Nginx只有fastcgi_params,后来发现很多人在定义SCRIPT_FILENAME时使用了硬编码的方式。
例如,fastcgi_param SCRIPT_FILENAME /var/www/foo$fastcgi_script_name。
于是为了规范用法便引入了fastcgi.conf。
不过这样的话就产生一个疑问:
为什么一定要引入一个新的配置文件,而不是修改旧的配置文件?
这是因为fastcgi_param指令是数组型的,
和普通指令相同的是:内层替换外层;
和普通指令不同的是:当在同级多次使用的时候,是新增而不是替换。
换句话说,如果在同级定义两次SCRIPT_FILENAME,那么它们都会被发送到后端,这可能会导致一些潜在的问题,为了避免此类情况,便引入了一个新的配置文件。
因此不再建议大家使用以下方式(搜了一下,网上大量的文章,并且nginx.conf的默认配置也是使用这种方式):
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
而推荐使用最新的方式:
include fastcgi.conf;
原文网址:http://www.cnblogs.com/skynet/p/4146083.html
=============================
https://blog.martinfjordvald.com/2013/04/nginx-config-history-fastcgi_params-versus-fastcgi-conf/
官网原文节选:
Because of how array directives inherit and interact the people using the old configuration style made it impossible to include the line in fastcgi_params. Doing this would have meant that SCRIPT_FILENAME would be defined twice and both would be sent to the backend, potentially causing confusing behaviour.
In 0.8.30 (released: 15th of December 2009) Igor then included fastcgi.conf which was the same as fastcgi_params except including the improved SCRIPT_FILENAME fastcgi_param. This meant that the community could now start recommending people include fastcgi.conf instead of recommending moving SCRIPT_FILENAME into fastcgi_params. New articles on the wiki mostly used this, the popular articles were slowly changed to use it and we were promoting it in the IRC support channel.
============================================================================
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
这句话其实就是定义php中用到的服务器变量 ——$_SERVER
http://wiki.nginx.org/NginxHttpFcgiModule 这个网址下有这么一句话:
This module allows Nginx to interact with FastCGI processes and control what parameters are passed to the process。
意思是 “服务器” 向你的处理php的cgi传递过去他需要的一些参数,而至少要有下面的两个参数php才能执行起来。
以下是例子
Below is an example of the minimally necessary parameters for PHP:
fastcgi_param SCRIPT_FILENAME /home/www/scripts/php$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string;
Parameter SCRIPT_FILENAME is used by PHP for determining the name of script. to execute, and QUERY_STRING contains the parameters of the request.
所以 我们在没有定义SCRIPT_FILENAME这个系统变量的时候 php是没法解释执行的
这个变量的定义可以写在nginx的配置文件nginx.conf里 也可以写在外部 用include的方式在nginx.conf里包含进来。
参考网址: http://www.shangxueba.com/jingyan/303616.html
相关推荐
LoadModule fastcgi_module modules/mod_fastcgi.so <IfModule fastcgi_module> AddHandler fastcgi-script .fcgi # you can put whatever extension you want FastCgiIpcDir /tmp FastCgiServer /home/m/Dev/...
LoadModule fastcgi_module modules/mod_fastcgi.so <IfModule fastcgi_module> AddHandler fastcgi-script .fcgi # you can put whatever extension you want FastCgiIpcDir /tmp FastCgiServer /home/m/Dev/...
1、默认使用curl命令访问: ... 2、修改nginx.conf配置文件,在http配置...# vim /usr/local/nginx/conf/fastcgi.conf fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 4、重载Nginx: # nginx -s reload 5、使用cur
fastcgi.impersonate = 1 cgi.rfc2616_headers = 1 cgi.fix_pathinfo = 1 cgi.force_redirect = 0 upload_tmp_dir =C:/php/temp extension_dir = "C:/php/temp" extension=php_bz2.dll extension=...
博文链接:https://kenter1643.iteye.com/blog/156330
1.修改lighttpd.conf 修改为自己的工作目录 var.server_root = "/home/caoft/lighttpd/lighttpd_websocket_fastcgi/http_server" var.state_dir = "/home/caoft/lighttpd/lighttpd_websocket_fastcgi/http_server"...
apache和C++实现fastcgi时Apache中httpd.conf的配置
fastcgi2.4.6的补丁文件,fastcgi2.4.6在Linux系统中直接解压安装会出现make: *** [mod_fastcgi.slo] 错误 1 这个问题,需要给fcgi.h这个文件打补丁才能正常安装
Debian+Nginx+PHP(FastCGI)+MySQL搭建LNMP服务器
测试平台:Windows 2008 R2 x64 (IIS7.5 FastCGI,Apache2.2.23,Apache2.4.3, Nginx 1.2.9) 包含 Non Thread Safe 和 Thread Safe 如果用的是 FastCGI 请使用 Non Thread Safe 版 php_opcache.dll 的使用方法 ...
nginx SSL 变量与 Apache mod_ssl 模块相比,这会在 nginx 中创建向后兼容的 SSL 变量;... 例如: location ~ \.php { include fastcgi.conf; include fastcgi_ssl_variables.conf;} 根据您的 nginx 版本,
亲测可用的fastcgi程序源码。我是用lighttpd+nginx+spawn-fcgi+fcgi-2.4.1搭建环境。使用C语言编写后台程序。goahead也可以用。apt install lighttpdapt install nginxapt ...avaliable/10-fastcgi.conf配置fastcgi
1、注释nginx.conf中的try_files(因为跟pathinfo.conf中的重复了),开启pathinfo.conf配置: location ~ [^/]\.php(/|$) { # comment try_files $uri =404; to enable pathinfo #try_files $uri =404; ...
/application/nginx-1.6.3/conf/fastcgi.conf.default /application/nginx-1.6.3/conf/fastcgi_params /application/nginx-1.6.3/conf/fastcgi_params.default /application/nginx-1.6.3/conf/koi-utf /application/...
fastcgi_intercept_errors on; sendfile on; #设置长连接 keepalive_timeout 65; #配置共享会话缓存大小 ssl_session_cache shared:SSL:10m; #配置会话超时时间 ssl_session_timeout 10m; #最大数据...
/usr/local/etc/nginx/valet/valet.conf location ~ \.php$ { # added params: fastcgi_buffers 16 16k; fastcgi_buffer_size 32k;}添加这些参数以使其生效后,请确保执行“代客重启”。 如果使用调试栏之类的东西...
经过志文工作室测试有效的相关配置主要内容如下: 代码如下:... fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_
fastcgi 安装的时候会出现error: ‘EOF’ was not declared in this scope错误,这个需要在/include/fcgio.h文件中加上 #include <stdio.h> 重新编译