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

502问题

php-fpm

修改项:

request_terminate_timeout

位置:

eg: /etc/php5/fpm2/pool.d/www.conf

; The timeout forserving 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 executionfor some reason. A value of '0' means 'off'.

; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)

; Default Value:0request_terminate_timeout= 300s

这个注释说明了,request_terminate_timeout 适用于,当max_execution_time由于某种原因无法终止脚本的时候,会把这个php-fpm请求干掉。

再看看max_execution_time的注释:这设置了脚本被解析器中止之前允许的最大执行时间,默认是30s。看样子,我这个请求应该是被max_execution_time这个设置干掉了。

0053f2ff6b6e65722d76b81bfda8c8fa.png

php.ini

修改项:

max_execution_time

位置:

eg: /etc/php5/fpm2/php.ini

; Maximum execution time of each script, inseconds

; http://php.net/max-execution-time

; Note: This directive is hardcoded to 0 forthe 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问题

处理项:

fastcgi_read_timeout

位置:

/etc/nginx/sites-enabled/default

d28ecbb075cfa5ad7e19ac6d35e39c9e.png

重启

/usr/sbin/nginx -s reload

备注:

php.ini 开启:post_max_size,upload_max_filesize,nginx,memory_limit,max_execution_time

如果修改不生效,查看  /etc/php5/fpm2/pool.d/www.conf 中配置

杀掉进程,确保php服务重新启动相关进程

pkill php5-fpm

参考地址:

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值