加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

nginx+php设置大文件请求上传(502及504问题处理)

发布时间:2020-12-13 22:16:23 所属栏目:PHP教程 来源:网络整理
导读:502问题 php-fpm 修改项:? request_terminate_timeout? 位置: eg: /etc/php5/fpm2/pool.d/www.conf ; The timeout for serving a single request after which the worker process will; be killed. This option should be used when the ‘ max_execution_t

502问题

  • php-fpm

修改项:?

request_terminate_timeout?

位置:

eg: /etc/php5/fpm2/pool.d/www.conf
; 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 = 300s

这个注释说明了,request_terminate_timeout 适用于,当max_execution_time由于某种原因无法终止脚本的时候,会把这个php-fpm请求干掉。
再看看max_execution_time的注释:这设置了脚本被解析器中止之前允许的最大执行时间,默认是30s。看样子,我这个请求应该是被max_execution_time这个设置干掉了。

?

  • php.ini

修改项:

  max_execution_time?

位置:

eg: /etc/php5/fpm2/php.ini
; Maximum execution time of each script,in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 300
  • 重启

service php5-fpm restart

?

总结:

web请求php执行时间受到2方面控制,一个是php.ini的max_execution_time(要注意的是sleep,http请求等待响应的时间是不算的,这里算的是真正的执行时间),另一个是php-fpm request_terminate_timeout 设置,这个算的是请求开始n秒。

?


?

504问题

处理项:

  request_terminate_timeout

位置:

  /etc/nginx/sites-enabled/default

  • 重启

/usr/sbin/nginx -s reload

?

参考地址:

https://blog.csdn.net/loophome/article/details/78604986

https://blog.csdn.net/lifei15731208550/article/details/89056867

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读