配置如下:
server {
listen 80 default;
server_name www.com;
index index.php;
root E:/php/htdocs/www/;
# 设置expires和max-age的时间
location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
expires 30d;
log_not_found off;
}
#设置不被防问的目录
location ~ ^/(application|library|var)/ {
deny all;
}
#将request指向index.php
location / {
index index.php index.html index.htm;
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php last;
}
#引用PHP CGI
location ~ .*\.(php|php5)?$ {
fastcgi_pass fastcgi_backend;
fastcgi_keep_conn on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
}
}
现象
其中一个是长连接 就会阻塞第二个连接,但第一长连接未断开 第二个短连接 就不会被阻塞
原因:
nginx fastcgi是单线程的,所以在解析php的时候 会被阻塞,而解析其他静态文件不会被阻塞,所以这个时间不能设得太长
解决方法
fastcgi_read_timeout 60; 重新启动系统 释放掉所有的链接
参考:
http://www.cnblogs.com/xiaouisme/archive/2012/08/01/2618398.html
| 1. .ginx收到cgi请求后,会看有多少个该cgi程序的进程(spawn-fcgi -F指定的参数),然后根据并发量来调用(调度)cgi程序。 我自己也不知道讲清楚没。其实我自己也不知道自己清楚没。:-) |
本文详细介绍了 Nginx 中 FastCGI 的配置方法,并针对 PHP 解析过程中出现的长连接阻塞问题提出了有效的解决方案,包括调整 fastcgi_read_timeout 参数等。
2260

被折叠的 条评论
为什么被折叠?



