PHP头条
热点:

PHP本身超时处理】

[ PHP-fpm ] 

配置:php-fpm.conf

  1. <?xml version="1.0" ?> 
  2.  
  3. <configuration> 
  4.  
  5. //...  
  6.  
  7.   Sets the limit on the number of simultaneous requests that will be served.  
  8.  
  9.   Equivalent to Apache MaxClients directive.  
  10.  
  11.   Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi  
  12.  
  13.   Used with any pm_style.  
  14.  
  15.   #php-cgi的进程数量  
  16.  
  17.   <value name="max_children">128</value> 
  18.  
  19.   The timeout (in seconds) for serving a single request after which the worker process will be terminated  
  20.  
  21.   Should be used when 'max_execution_time' ini option does not stop script execution for some reason  
  22.  
  23.   '0s' means 'off'  
  24.  
  25.  #php-fpm 请求执行超时时间,0s为永不超时,否则设置一个 Ns 为超时的秒数  
  26.  
  27.   <value name="request_terminate_timeout">0s</value> 
  28.  
  29.   The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file  
  30.  
  31.   '0s' means 'off'  
  32.  
  33.   <value name="request_slowlog_timeout">0s</value> 
  34.  
  35. </configuration> 

说明:

在 php.ini 中,有一个参数 max_execution_time 可以设置 PHP 脚本的最大执行时间,但是,在 php-cgi(php-fpm) 中,该参数不会起效。真正能够控制 PHP 脚本最大执行时:

  1. <value name="request_terminate_timeout">0s</value>   

就是说如果是使用 mod_php5.so 的模式运行 max_execution_time 是会生效的,但是如果是php-fpm模式中运行时不生效的。

延伸阅读:

http://blog.s135.com/file_get_contents/

[ PHP ]

配置:php.ini

选项:

  1. max_execution_time = 30 

或者在代码里设置:

  1. ini_set("max_execution_time", 30);  
  2.  
  3. set_time_limit(30); 

说明:

对当前会话生效,比如设置0一直不超时,但是如果php的 safe_mode 打开了,这些设置都会不生效。

效果一样,但是具体内容需要参考php-fpm部分内容,如果php-fpm中设置了 request_terminate_timeout 的话,那么 max_execution_time 就不生效。


www.phpzy.comtrue/php/2425.htmlTechArticlePHP本身超时处理】 [ PHP-fpm ] 配置:php-fpm.conf ? xml version = 1.0 ? configuration //... Setsthelimitonthenumberofsimultaneousrequeststhatwillbeserved. EquivalenttoApacheMaxClientsdirectiv...

相关文章

相关频道:

PHP之友评论

今天推荐