Nginx中ngx_http_fastcgi_module
转发请求到 FastCGI 服务器器,不不⽀支持 php 模块⽅方式
指令:
15.1 fastcgi_pass
设置 fastcgi 服务器器的地址。地址可以指定为域名
或 IP 地址,以及端⼝口
Syntax: fastcgi_pass address;
Default: —
Context: location, if in location
fastcgi_pass localhost:9000;
15.2 fastcgi_index
fastcgi 默认的主⻚页资源
Syntax: fastcgi_index name;
Default: —
Context: http, server, location
15.3 fastcgi_param
设置传递给 fastCGI 服务器器的参数值,可以是⽂文
本,变量量或组合
Syntax: fastcgi_param parameter value
[if_not_empty];
Default: —
Context: http, server, location
15.4 fastcgi_cache_path
-
Syntax: fastcgi_cache_path path
[levels=levels]
[use_temp_path=on|off]
keys_zone=name:size [inactive=time]
[max_size=size]
[manager_files=number]
[manager_sleep=time]
[manager_threshold=time]
[loader_files=number]
[loader_sleep=time]
[loader_threshold=time]
[purger=on|off] [purger_files=number]
[purger_sleep=time]
[purger_threshold=time];
Default: —
Context: http
location ~* \.php$ {
fastcgi_pass 后端fpm服务器器IP:9000
;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /u
sr/share/nginx/html$fastcgi_script_n
ame;
include fastcgi_params;
}
15.5 fastcgi_cache
调⽤用指定的缓存空间来缓存数据
Syntax: fastcgi_cache zone | off;
Default: fastcgi_cache off;
Context: http, server, location
15.6 fastcgi_cache_key
定义⽤用作缓存项的 key 的字符串串
Syntax: fastcgi_cache_key string;
Default: —
Context: http, server, location
fastcgi_cache_key localhost:9000$req
uest_uri;
15.7 fastcgi_cache_methods
为哪些请求⽅方法使⽤用缓存
Syntax: fastcgi_cache_methods GET |
HEAD | POST ...;
Default: fastcgi_cache_methods GET
HEAD;
Context: http, server, location
15.8 fastcgi_cache_min_uses
缓存空间中的缓存项在 inactive 定义的⾮非活动时间
内⾄至少要被访问到此处所指定的次数⽅方可被认作活
动项
Syntax: fastcgi_cache_min_uses
number;
Default: fastcgi_cache_min_uses 1;
Context: http, server, location
15.9 fastcgi_keep_conn
收到后端服务器器响应后, fastcgi 服务器器是否关闭
连接,建议启⽤用⻓长连接
Syntax: fastcgi_keep_conn on | off;
Default: fastcgi_keep_conn off;
Context: http, server, location
15.10 fastcgi_cache_valid
不不同的响应码各⾃自的缓存时⻓长
Syntax: fastcgi_cache_valid [code
...] time;
Default: —
Context: http, server, location
fastcgi_cache_valid 200 302 10m;
fastcgi_cache_valid 404 1m;