问题描述
我使用Apache +的mod_fastcgi + PHP-FPM。我试图解析大文件和PHP脚本的max_execution_time设置为0,但在错误日志消息在30秒后脚本失败:
FastCGI的:COMM与服务器/ usr / lib目录/ cgi-bin目录/ LZ-FCGI中止:空闲超时(30秒)。
在下面你CONFIGS可以看到-idle超时指令设置到900秒,我很困惑所在服务器获得价值30多岁?
当我切换到mod_php的或mod_fcgid它的确定,为此MODS所有适当的设置正在
请帮助在哪里看?
下面CONFIGS:
阿帕奇全球的conf例如
< IfModule mod_fastcgi.c>
AddHandler的FastCGI的脚本.fcgi
FastCgiIpcDir在/ usr / local / etc中/ PHP-FPM /
FastCgiConfig -singleThreshold 100 -killInterval 300 -idle超时900 -maxClassProcesses 1 -pass头HTTP_AUTHORIZATION
FastCgiWrapper / usr / lib目录/的Apache2 / suexec的
#AddHandler PHP5-FCGI的.php .php3 .php4 .php5一个.phtml
#Action PHP5-FCGI / PHP5-FCGI
#Alias / PHP5-FCGI / usr / lib目录/ cgi-bin目录/ PHP5-FCGI
< / IfModule>
虚拟主机的例子
<虚拟主机*:80>
服务器名site.ru
DocumentRoot的/var/www/site.ru
ServerAlias www.site.ru
SuexecUserGroup用户群
ScriptAlias指令/的cgi-bin /在/ var / WWW /网站/ cgi-bin目录/ < IfModule mod_fastcgi.c>
FastCgiExternalServer / usr / lib目录/ cgi-bin目录/ LZ-FCGI -socket /tmp/lz-fcgi.sock -idle超时900 -user用户 - 组组
AddHandler的LZ-FCGI的.php .php3 .php4 .php5一个.phtml
行动LZ-FCGI / LZ-FCGI
别名/ LZ-FCGI / usr / lib目录/ cgi-bin目录/ LZ-FCGI
< / IfModule>
PHP-FPM的conf
;;;;;;;;;;;;;;;;;;;;;
; FPM配置;
;;;;;;;;;;;;;;;;;;;;;;在此配置文件中的所有相对路径是相对于PHP的安装
; preFIX目录(/ usr)。此preFIX可以通过使用被dynamicaly改变
;在命令行-p的说法。;包括一个或多个文件。如果(3)中存在的glob,它是用来包括一串
;从水珠(3)病毒码文件。该指令可以无处不在的使用
;文件。
;也可以使用相对路径。他们将通过pfixed $ P $:
; - 如果它被设置全局preFIX(-p实际参数的)
; - 的/ usr否则
;包括=等/ PHP5 / FPM / * CONF。;;;;;;;;;;;;;;;;;;
;全局选项;
;;;;;;;;;;;;;;;;;;[全球]
; PID文件
;注:默认的preFIX是/ var
;默认值:无
PID = /var/run/php5-fpm.pid;错误日志文件
;如果它被设置为系统日志,日志发送到syslogd,而不是被写入
;在本地文件。
;注:默认的preFIX是/ var
;默认值:登录/ PHP-fpm.log
的error_log = /var/log/php5-fpm.log; SYSLOG_FACILITY用于指定哪种类型的节目被记录的
;信息。这让syslogd的规定,从不同的设施信息
;将不同的处理。
;请参阅可能值的syslog(3)(前守护当量LOG_DAEMON)
;默认值:守护
; syslog.facility =守护进程; syslog_ident是ppended每一个消息$ P $。如果你有多个FPM
;在同一台服务器上运行的实例,则可以更改默认值
;它必须满足共同需求。
;默认值:PHP-FPM
; syslog.ident = PHP-FPM;日志级别
;可能的值:警告,错误,警告,通知,调试
;默认值:通知
; LOG_LEVEL =通知;如果这个数字的孩子处理退出的时间内SIGSEGV或SIGBUS
;间隔组由emergency_restart_interval然后FPM将重新启动。值
; 0表示关。
;默认值:0
; emergency_restart_threshold = 0;通过emergency_restart_interval使用的时间间隔,以确定何时
;优美的重启将开始。这可以是解决有用
;意外损坏在加速器的共享内存。
;可用单位:秒(econds),M(inutes),H(我们的)或D(AYS)
;默认值单位:秒
;默认值:0
; emergency_restart_interval = 0;子进程时限等待来自主站的信号的反应。
;可用单位:秒(econds),M(inutes),H(我们的)或D(AYS)
;默认值单位:秒
;默认值:0
; process_control_timeout = 0;流程FPM的最大数目将叉。这已被设计来控制
;很多泳池内使用动态PM时的处理全球多家。
;所以请谨慎使用。
;注:值为0表示没有限制
;默认值:0
;的process.max = 128;指定尼斯(2)优先适用于主进程(仅当设定)
;该值可以从-19(最高优先级)至20(低优先级)变化
;注: - 如果FPM主进程启动以root这只会工作
; - 池进程将继承主进程的优先级
;除非另有说明,
;默认值:未设
; process.priority = -19;发送FPM背景。设置为无,以保持FPM在前台进行调试。
;缺省值:yes
;以进程= YES;设置主进程打开的文件描述符RLIMIT。
;默认值:系统定义的值
; rlimit_files = 1024;设置最大芯尺寸为RLIMIT主进程。
;可能的值:无限或整数大于或等于0
;默认值:系统定义的值
; = RLIMIT_CORE 0;指定事件机制FPM将使用。以下是可供选择:
; - 选择(POSIX任何OS)
; - 民意调查(POSIX任何OS)
; - epoll的(Linux和GT = 44年2月5日)
; - kqueue的(FreeBSD的> = 4.1,OpenBSD的> = 2.9,NetBSD的> = 2.0)
; - 为/ dev /民意调查(的Solaris> = 7)
; - 端口(的Solaris> = 10)
;默认值:未设置(自动检测)
; events.mechanism = epoll的;;;;;;;;;;;;;;;;;;;;
;池定义;
;;;;;;;;;;;;;;;;;;;;;子进程的多个池可以用不同的听音开始
;港口和不同的管理选项。池的名字将是
;在日志和统计使用。有上池的数目没有限制,该
; FPM可以处理。您的系统会告诉你啦:);要配置池,建议有每一.conf文件
;池以下目录:
包括=的/ etc / PHP5 / FPM / pool.d / *。CONF
PHP-PFM池的conf
;启动一个名为'WWW'新池。
;变量$池可以我们在任何指令使用,并且将被替换
;池名称(WWW这里)
[LZ];每池preFIX
;它仅适用于以下指令:
; - slowlog
; - '听'(unixsocket)
; - 的chroot
; - CHDIR
; - php_values
; - php_admin_values
;如果没有设置,全局preFIX(或/ usr)适用替代。
;注:此指令还可以相对于全球preFIX。
;默认值:无
; preFIX = /路径/要/池/ $池; Unix用户/组进程
;注意:用户是必需的。如果未设置的组,默认用户的组
;将会被使用。
用户= letomzimoy
组= letomzimoy;在其上的地址接受FastCGI的请求。
;有效语法是:
; ip.add.re.ss:口 - 在一个TCP套接字收听特定的地址
;特定端口;
; 口 - 在一个TCP套接字听上所有地址
;特定端口;
; '/路径/要/ UNIX /插座' - 对Unix套接字听。
;注意:这个值是强制性的。
;听= 127.0.0.1:9000
听= /tmp/lz-fcgi.sock;设置听(2)积压。 -1的值表示无限制。
;默认值:128(-1在FreeBSD和OpenBSD)
; listen.backlog = -1;对于Unix套接字设置权限,如果一个人使用。在Linux中,读/写
;权限必须以允许从Web服务器的连接进行设置。许多
; BSD衍生系统允许的权限,无论连接。
;默认值为:用户和用户组设置为正在运行的用户
;模式被设置为0666
; listen.owner = www数据
; listen.group = www数据
; listen.mode = 0666;这允许连接的FastCGI客户IPv4地址的列表。
;等同于原始的FCGI_WEB_SERVER_ADDRS环境变量
; PHP FCGI(5.2.2+)。有意义只能用TCP监听套接字。每个地址
;必须用逗号分隔。如果此值留空,连接将
;从任何IP地址接受。
;默认值:任何
; listen.allowed_clients = 127.0.0.1;指定尼斯(2)优先申请到池进程(仅在设置时)
;该值可以从-19(最高优先级)至20(低优先级)变化
;注: - 如果FPM主进程启动以root这只会工作
; - 池进程将继承主进程的优先级
;除非另有说明,
;默认值:未设
;优先级= -19;选择进程管理器将如何控制子进程的数量。
;可能的值:
;静态 - 固定数量的子进程(pm.max_children);
;动态 - 子进程的数量被设置动态地基于所述
;以下指令。在这个过程中的管理,将有
;总是至少1孩子。
; pm.max_children - 儿童的最大数目,可以
;在同一时间活着。
; pm.start_servers - 在启动时创建的儿童人数。
; pm.min_spare_servers - 儿童的空闲的最小数量
;状态(等待处理)。如果数字
; 空闲进程低于此
;号码,然后有些孩子将被创建。
; pm.max_spare_servers - 儿童的空闲的最大数量
;状态(等待处理)。如果数字
; 空闲过程比这更大
;号码,然后有些孩子就会被杀死。
;按需 - 在启动时创建无儿无女。儿童可以当分叉
;新的请求将连接。以下参数被使用:
; pm.max_children - 儿童的最大数目
;可以在同一时间活着。
; pm.process_idle_timeout - 的秒数之后,
;空闲进程将被杀死。
;注意:这个值是强制性的。
PM =按需;当点被设置为静态和要创建子进程的数量
;当点被设置为动态或按需的子进程的最大数目。
;此值设置上同时发生的请求,将数量限制
;提供服务。相当于ApacheMaxClients指令与mpm_ prefork。
;相当于在原来的PHP的PHP_FCGI_CHILDREN环境变量
; CGI。以下默认值是基于没有太多的资源的服务器上。别
;忘记调整时。*,以满足您的需求。
;注意:当点被设置为静态,动态或按需二手
;注意:这个值是强制性的。
pm.max_children = 8;在启动时创建的子进程的数量。
;注意:当点被设置为'动态'仅用于
;默认值:min_spare_servers +(max_spare_servers - min_spare_servers)/ 2
pm.start_servers = 2;所需的最小数量的空闲服务器进程。
;注意:当点被设置为'动态'仅用于
;注:强制下午,当设置为动态
pm.min_spare_servers = 1;空闲服务器进程所需的最大数目。
;注意:当点被设置为'动态'仅用于
;注:强制下午,当设置为动态
pm.max_spare_servers = 3;之后闲置的过程中会被杀死的秒数。
;注:当PM设置为按需仅用于
;默认值:10秒
pm.process_idle_timeout = 900秒;;每个子进程重生前,应执行的请求数。
;这可以是解决在第三方库内存泄漏很有用的。为
;无尽的请求处理指定0。相当于PHP_FCGI_MAX_REQUESTS。
;默认值:0
pm.max_requests = 500;该URI来查看FPM状态页。如果没有设置这个值,没有URI会
;公认的状态页。它显示了以下信息:
;池 - 池的名称;
;进程管理器 - 静态,动态或按需;
;开始时间 - 日期和时间FPM已启动;
;自启动 - 秒数FPM以来已经开始;
;接受连接 - 请求由池接受了数;
;听排队 - 请求的数量挂起的队列
;连接(见积压听(2));
;最大听队列 - 队列中的请求的最大数
;因为FPM已经开始挂起连接;
;侦听队列LEN - 挂起连接的套接字队列的大小;
;空闲进程 - 空闲进程的数量;
;活动进程 - 活动进程的数量;
;总流程 - 空闲+活动进程的数量;
;最大活动进程 - 因为FPM活动进程的最大数量
;已开始;
;最大的孩子达到了 - 的次数,这个过程已经达到极限,
;下午的时候尝试启动更多的孩子(仅适用于
;下午'动态'和'按需');
;值被实时更新。
;输出示例:
;池:WWW
;进程管理:静态
;开始时间:01 /七月/ 2011:17:53:49 +0200
;开始时间:62636
;康涅狄格州接受:190460
;听队列:0
;最大监听队列:1
;听队列LEN:42
;空闲进程:4
;活动进程:11
;总进程:15
;最大活动流程:12
;最大的孩子达到:0
;
;默认情况下,状态页输出格式为文本/纯。无论是传递
; HTML,XML或JSON'在查询字符串将返回对应
;输出语法。例:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; http://www.foo.bar/status?xml
;
;默认情况下,状态页面只输出短路状态。在传递'全'
;查询字符串还将为每个池进程返回状态。
;例:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
; http://www.foo.bar/status?xml&full
;完整的状态返回为每个进程:
; PID - 进程的PID;
;状态 - 进程的状态(空闲,跑步,...);
;开始时间 - 进程已经开始的日期和时间;
;自从开始 - 的秒数,因为进程已经开始;
;请求 - 进程已投放的请求的数量;
;申请时间 - 在请求微秒的持续时间;
;申请方法 - 请求方法(GET,POST,...);
;请求URI - 查询字符串请求的URI;
;内容长度 - 请求(只POST)的内容长度;
;用户 - 用户(PHP_AUTH_USER)(或 - 如果没有设置);
;脚本 - 主要脚本调用(或 - 如果没有设置);
;最后一个请求CPU - 在%的CPU的最后一个请求消耗
;它总是0,如果进程不处于空闲状态
;因为CPU计算完成后请求
;处理终止;
;最后一个请求的内存 - 的最后一个请求消耗的内存量最高
;它总是0,如果进程不处于空闲状态
;因为内存计算完成后请求
;处理终止;
;如果过程处于空闲状态,则信息都涉及到
;最后一个请求的过程中一直担任。否则信息相关的
;当前请求被服务。
;输出示例:
; ************************
; PID:31330
;状态:运行
;开始时间:01 /七月/ 2011:17:53:49 +0200
;开始时间:63087
;请求:12808
;申请时间:1250261
;请求方法:GET
;请求URI:/test_mem.php?N=10000
;内容长度:0
;用户: -
;脚本:/home/fat/web/docs/php/test_mem.php
;最后一个请求CPU:0.00
;最后一个请求的内存:0
;
;注意:有一个实时的FPM状态监控样本网页可用
;它的问世在:$ {preFIX} /share/fpm/status.html
;
;注:值必须以斜线(/)开始。该值可以是
;任何东西,但它可能不是一个好主意,使用PHP扩展或
;可以用一个真实的PHP文件相冲突。
;默认值:未设置
; pm.status_path = /状态;平安URI调用FPM的监控页面。如果没有设置这个值,不
; URI将被识别为平页面。这可以用来从外部测试
;这FPM是活的响应,或
; - 创建FPM可用性图(RRD或此类);
; - 如果没有响应(负载平衡),从组中删除服务器;
; - 触发警报的运营团队(24/7)。
;注:值必须以斜线(/)开始。该值可以是
;任何东西,但它可能不是一个好主意,使用PHP扩展或
;可以用一个真实的PHP文件相冲突。
;默认值:未设置
; ping.path = /平;该指令可用于定制ping请求的响应。该
;响应格式为文本/纯用200响应code。
;默认值:乒乓
; ping.response =乒乓;访问日志文件
;默认值:不设置
; access.log的=记录/ $ pool.access.log;访问日志格式。
;下面的语法允许
; %%: 人物
; %C:请求所使用的CPU%
;它可以接受的格式如下:
; - %{}用户℃,只有用户CPU
; - %{}系统℃,只有系统CPU
; - %{}总℃,用户+系统CPU(默认)
; %D:花费时间来服务请求
;它可以接受的格式如下:
; - %{}秒D(默认)
; - %{}毫秒ð
; - %{}蜜梨ð
; - %{}微秒ð
; - %{}微ð
; %E:环境变量(同$ _ENV或$ _ SERVER)
;它必须与拥抱相关联,以指定将env的名称
;变量。有些exemples:
; - 服务器的细节,如:%{REQUEST_METHOD} e或%{SERVER_PROTOCOL} e所
; - HTTP头,如:%{HTTP_HOST} e或%{HTTP_USER_AGENT} e所
; %F:脚本文件名
; %L:请求的内容长度(对于POST请求只)
; %M:请求方法
; %M:内存峰值由PHP分配
;它可以接受的格式如下:
; - %{字节} M(默认)
; - %{千字节} M
; - %{公斤} M
; - %{兆} M
; - %{万} M
; %N:池名称
; %○:输出中的头
;它必须与拥抱相关联,以指定的标题的名称:
; - %{内容类型}Ø
; - %{X-技术,通过}Ø
; - %{Transfert-编码}Ø
; - ....
; %P:响应请求孩子的PID
; %P:响应请求的儿童家长的PID
; %Q:查询字符串
; %问:?如果查询字符串的字符存在
; %R:请求URI(没有查询字符串,请参阅%q和%Q)
; %R:远程IP地址
; %S:状态(响应code)
; %T:服务器时间接收请求
;它可以接受的strftime(3)格式:
; %D /%B /%Y:%H:%M:%S%Z(默认)
; %T:时间日志已被写入(请求已完成)
;它可以接受的strftime(3)格式:
; %D /%B /%Y:%H:%M:%S%Z(默认)
; %u:远程用户
;
;默认值:%R - %U%T \\%M%r \\%S
; access.format =%R - %U%T \\%M%R%Q%Q \\%s%F%{}蜜梨D%{公斤} M%C %%;缓慢请求日志文件
;默认值:未设置
;注意:如果request_slowlog_timeout设置slowlog是强制性
; slowlog =登录/ $ pool.log.slow;为服务于单个请求超时之后,一个PHP回溯会
;转储到slowlog'文件。 '0'表示'关'的价值。
;可用单位:秒(econds)(默认),M(inutes),H(我们的)或D(AYS)
;默认值:0
; request_slowlog_timeout = 0;为服务于单个请求超时之后,工作进程
;被杀死。这个选项应该被用来当'的max_execution_timeINI选项
;不停止出于某种原因,脚本执行。 0值意味着关闭。
;可用单位:秒(econds)(默认),M(inutes),H(我们的)或D(AYS)
;默认值:0
; request_terminate_timeout = 0;设置打开文件描述符RLIMIT。
;默认值:系统定义的值
; rlimit_files = 1024;设置最大芯尺寸RLIMIT。
;可能的值:无限或整数大于或等于0
;默认值:系统定义的值
; = RLIMIT_CORE 0; chroot环境在开始这个目录。这个值必须被定义为一个
;绝对路径。如果没有设置这个值,不使用chroot环境。
;注意:您可以preFIX以'$preFIX执行chroot池preFIX或者一个
;它的子目录。如果没有设置池preFIX,全球preFIX
;将被用来代替。
;注:的chrooting是一个很大的安全保护功能,应当使用时
;可能。然而,所有的PHP路径将是相对于所述的chroot
; (error_log中,sessions.save_path,...)。
;默认值:未设置
;的chroot =; CHDIR在开始这个目录。
;注:可以使用相对路径。
;默认值:当前目录或/时的chroot
CHDIR = /;重定向工人输出和错误到主要错误日志。如果没有设置,输出和
;标准错误将根据FastCGI的规格被重定向到/ dev / null的。
;注意:highloaded environement,这可能会导致在页面中有一些延迟
;过程时间(几毫秒)。
;默认值:无
; catch_workers_output = YES;限制主脚本FPM的扩展将允许进行解析。这可以
;在Web服务器端prevent配置错误。您应该只限制
; FPM为.php扩展prevent恶意用户使用其他扩展
; exectute PHP code。
;注意:设置为空值,允许所有扩展。
;默认值:.PHP
; security.limit_extensions =的.php .php3 .php4 .php5;传似LD_LIBRARY_PATH环境变量。所有$变量都取自
;当前的环境。
;默认值:干净ENV
; ENV [HOSTNAME] = $ HOSTNAME
; ENV [路径] =在/ usr / local / bin目录:在/ usr / bin中:/ bin中
; ENV [TMP = / tmp目录
; ENV [TMPDIR = / tmp目录
; ENV [TEMP = / tmp目录;附加的php.ini定义,具体到该池的工人。这些设置
;覆盖在php.ini pviously定义的值$ P $。这些指令是
;同为PHP SAPI:
; php_value /的php_flag - 你可以设置经典INI定义了一种
;从PHP调用'的ini_set'覆盖。
; php_admin_value / php_admin_flag - 这些指令将不会被覆盖
; PHP通话的ini_set
;对于PHP_ *标志,有效值为开,关,1,0,真,假,是或否。;定义扩展名将加载从相应的共享扩展
; extension_dir中。定义'disable_functions选项或disable_classes不会
;覆盖previously定义的php.ini值,但将追加新的价值
;代替。;注意:路径INI选项可以是相对的,并且将与preFIX扩大
; (池,全球或/ usr);默认值:无默认情况下,除了在php.ini中的价值定义,
;在启动时用-d参数指定
; php_admin_value [sendmail_path] = / usr / sbin目录/ sendmail的-t -i -f www@my.domain.com
;的php_flag [display_errors设置] =关闭
; php_admin_value [error_log中] = /var/log/fpm-php.www.log
; php_admin_flag [log_errors =上
; php_admin_value [memory_limit的= 32M
我目前找到问题的症结所在。我有同样的指令数的虚拟主机
FastCgiExternalServer / usr / lib目录/ cgi-bin目录/ LZ-FCGI -socket /tmp/lz-fcgi.sock -idle超时900 -user用户 - 组组
当我加入-idle超时每个虚拟主机配置的所有一切工作,正如预期的那样,适用于请求超时
<虚拟主机site.ru:80>
服务器名site.ru
DocumentRoot的/var/www/site.ru
ServerAlias www.site.ru
SuexecUserGroup用户群
ScriptAlias指令/的cgi-bin /在/ var / WWW /网站/ cgi-bin目录/ < IfModule mod_fastcgi.c>
FastCgiExternalServer / usr / lib目录/ cgi-bin目录/ LZ-FCGI -socket /tmp/lz-fcgi.sock -idle超时900 -user用户 - 组组
AddHandler的LZ-FCGI的.php .php3 .php4 .php5一个.phtml
行动LZ-FCGI / LZ-FCGI
别名/ LZ-FCGI / usr / lib目录/ cgi-bin目录/ LZ-FCGI
< / IfModule>
< /虚拟主机><虚拟主机secondsite.ru:80>
服务器名secondsite.ru
DocumentRoot的/var/www/secondsite.ru
ServerAlias www.secondsite.ru
SuexecUserGroup用户群
ScriptAlias指令/的cgi-bin /在/ var / WWW / secondsite / cgi-bin目录/ < IfModule mod_fastcgi.c>
FastCgiExternalServer / usr / lib目录/ cgi-bin目录/ LZ-FCGI -socket /tmp/lz-fcgi.sock -idle超时900 -user用户 - 组组
AddHandler的LZ-FCGI的.php .php3 .php4 .php5一个.phtml
行动LZ-FCGI / LZ-FCGI
别名/ LZ-FCGI / usr / lib目录/ cgi-bin目录/ LZ-FCGI
< / IfModule>
< /虚拟主机>
I'm using Apache + mod_fastcgi + php-fpm. I'm trying parse big file and set in php script max_execution_time to 0, but script fails after 30 seconds with message in error log:"FastCGI: comm with server "/usr/lib/cgi-bin/lz-fcgi" aborted: idle timeout (30 sec)".In configs below you can see that -idle-timeout directive is set to 900 seconds and I'm confused where the server gets value 30s?When I switch to mod_php or mod_fcgid it's ok and all appropriate settings for this mods are workingPlease, help where to look?
Here configs:Apache global conf example
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
FastCgiIpcDir /usr/local/etc/php-fpm/
FastCgiConfig -singleThreshold 100 -killInterval 300 -idle-timeout 900 -maxClassProcesses 1 -pass-header HTTP_AUTHORIZATION
FastCgiWrapper /usr/lib/apache2/suexec
#AddHandler php5-fcgi .php .php3 .php4 .php5 .phtml
#Action php5-fcgi /php5-fcgi
#Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
</IfModule>
Vhost example
<VirtualHost *:80 >
ServerName site.ru
DocumentRoot /var/www/site.ru
ServerAlias www.site.ru
SuexecUserGroup user group
ScriptAlias /cgi-bin/ /var/www/site/cgi-bin/
<IfModule mod_fastcgi.c>
FastCgiExternalServer /usr/lib/cgi-bin/lz-fcgi -socket /tmp/lz-fcgi.sock -idle-timeout 900 -user user -group group
AddHandler lz-fcgi .php .php3 .php4 .php5 .phtml
Action lz-fcgi /lz-fcgi
Alias /lz-fcgi /usr/lib/cgi-bin/lz-fcgi
</IfModule>
php-fpm conf
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;
; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr). This prefix can be dynamicaly changed by using the
; '-p' argument from the command line.
; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p arguement)
; - /usr otherwise
;include=etc/php5/fpm/*.conf
;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;
[global]
; Pid file
; Note: the default prefix is /var
; Default Value: none
pid = /var/run/php5-fpm.pid
; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /var
; Default Value: log/php-fpm.log
error_log = /var/log/php5-fpm.log
; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon
; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm
; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice
; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0
; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0
; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0
; The maximum number of processes FPM will fork. This has been design to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128
; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool process will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; process.priority = -19
; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes
; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Specify the event mechanism FPM will use. The following is available:
; - select (any POSIX os)
; - poll (any POSIX os)
; - epoll (linux >= 2.5.44)
; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll (Solaris >= 7)
; - port (Solaris >= 10)
; Default Value: not set (auto detection)
; events.mechanism = epoll
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)
; To configure the pools it is recommended to have one .conf file per
; pool in the following directory:
include=/etc/php5/fpm/pool.d/*.conf
php-pfm pool conf
; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[lz]
; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = letomzimoy
group = letomzimoy
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
;listen = 127.0.0.1:9000
listen = /tmp/lz-fcgi.sock
; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
;listen.backlog = -1
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0666
;listen.owner = www-data
;listen.group = www-data
;listen.mode = 0666
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1
; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; priority = -19
; Choose how the process manager will control the number of child processes.
; Possible Values:
; static - a fixed number (pm.max_children) of child processes;
; dynamic - the number of child processes are set dynamically based on the
; following directives. With this process management, there will be
; always at least 1 children.
; pm.max_children - the maximum number of children that can
; be alive at the same time.
; pm.start_servers - the number of children created on startup.
; pm.min_spare_servers - the minimum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is less than this
; number then some children will be created.
; pm.max_spare_servers - the maximum number of children in 'idle'
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = ondemand
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 8
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 2
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
pm.process_idle_timeout = 900s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500
; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. It shows the following informations:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
; start since - number of seconds since FPM has started;
; accepted conn - the number of request accepted by the pool;
; listen queue - the number of request in the queue of pending
; connections (see backlog in listen(2));
; max listen queue - the maximum number of requests in the queue
; of pending connections since FPM has started;
; listen queue len - the size of the socket queue of pending connections;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes;
; max active processes - the maximum number of active processes since FPM
; has started;
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic' and 'ondemand');
; Value are updated in real time.
; Example output:
; pool: www
; process manager: static
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 62636
; accepted conn: 190460
; listen queue: 0
; max listen queue: 1
; listen queue len: 42
; idle processes: 4
; active processes: 11
; total processes: 15
; max active processes: 12
; max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' in the query string will return the corresponding
; output syntax. Example:
; http://www.foo.bar/status
; http://www.foo.bar/status?json
; http://www.foo.bar/status?html
; http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
; http://www.foo.bar/status?xml&full
; The Full status returns for each process:
; pid - the PID of the process;
; state - the state of the process (Idle, Running, ...);
; start time - the date and time the process has started;
; start since - the number of seconds since the process has started;
; requests - the number of requests the process has served;
; request duration - the duration in µs of the requests;
; request method - the request method (GET, POST, ...);
; request URI - the request URI with the query string;
; content length - the content length of the request (only with POST);
; user - the user (PHP_AUTH_USER) (or '-' if not set);
; script - the main script called (or '-' if not set);
; last request cpu - the %cpu the last request consumed
; it's always 0 if the process is not in Idle state
; because CPU calculation is done when the request
; processing has terminated;
; last request memory - the max amount of memory the last request consumed
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
; ************************
; pid: 31330
; state: Running
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 63087
; requests: 12808
; request duration: 1250261
; request method: GET
; request URI: /test_mem.php?N=10000
; content length: 0
; user: -
; script: /home/fat/web/docs/php/test_mem.php
; last request cpu: 0.00
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: ${prefix}/share/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
; anything, but it may not be a good idea to use the .php extension or it
; may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping
; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong
; The access log file
; Default: not set
;access.log = log/$pool.access.log
; The access log format.
; The following syntax is allowed
; %%: the '%' character
; %C: %CPU used by the request
; it can accept the following format:
; - %{user}C for user CPU only
; - %{system}C for system CPU only
; - %{total}C for user + system CPU (default)
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{miliseconds}d
; - %{mili}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some exemples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
; %l: content-length of the request (for POST request only)
; %m: request method
; %M: peak of memory allocated by PHP
; it can accept the following format:
; - %{bytes}M (default)
; - %{kilobytes}M
; - %{kilo}M
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: ouput header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
; - %{Transfert-Encoding}o
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
; %s: status (response code)
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
; possible. However, all PHP paths will be relative to the chroot
; (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot =
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = /
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
; php_value/php_flag - you can set classic ini defines which can
; be overwritten from PHP call 'ini_set'.
; php_admin_value/php_admin_flag - these directives won't be overwritten by
; PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr)
; Default Value: nothing is defined by default except the values in php.ini and
; specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
I'm currently find where the problem lies. I have several virtual hosts with the same directive
FastCgiExternalServer /usr/lib/cgi-bin/lz-fcgi -socket /tmp/lz-fcgi.sock -idle-timeout 900 -user user -group group
When I add -idle-timeout to each Vhost config all everything was working just as expected, timeout applied to requests
<VirtualHost site.ru:80 >
ServerName site.ru
DocumentRoot /var/www/site.ru
ServerAlias www.site.ru
SuexecUserGroup user group
ScriptAlias /cgi-bin/ /var/www/site/cgi-bin/
<IfModule mod_fastcgi.c>
FastCgiExternalServer /usr/lib/cgi-bin/lz-fcgi -socket /tmp/lz-fcgi.sock -idle-timeout 900 -user user -group group
AddHandler lz-fcgi .php .php3 .php4 .php5 .phtml
Action lz-fcgi /lz-fcgi
Alias /lz-fcgi /usr/lib/cgi-bin/lz-fcgi
</IfModule>
</VirtualHost>
<VirtualHost secondsite.ru:80 >
ServerName secondsite.ru
DocumentRoot /var/www/secondsite.ru
ServerAlias www.secondsite.ru
SuexecUserGroup user group
ScriptAlias /cgi-bin/ /var/www/secondsite/cgi-bin/
<IfModule mod_fastcgi.c>
FastCgiExternalServer /usr/lib/cgi-bin/lz-fcgi -socket /tmp/lz-fcgi.sock -idle-timeout 900 -user user -group group
AddHandler lz-fcgi .php .php3 .php4 .php5 .phtml
Action lz-fcgi /lz-fcgi
Alias /lz-fcgi /usr/lib/cgi-bin/lz-fcgi
</IfModule>
</VirtualHost>
这篇关于的mod_fastcgi空闲超时无法工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!