zoukankan      html  css  js  c++  java
  • nginx+php设置大文件请求上传(502及504问题处理)

    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问题

    处理项:

      fastcgi_read_timeout

    位置:

      /etc/nginx/sites-enabled/default

    • 重启

    /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

  • 相关阅读:
    Charles截获iPhone网络请求
    android小Demo--圆球跟随手指轨迹移动
    《腾讯网UED体验设计之旅》读后感
    eatwhatApp开发实战(十四)
    [Unity2d系列教程] 006.Unity如何根据图片自动生成Animator
    [Unity2d系列教程] 005.Unity如何使用外部触控插件FingerGuesture
    eatwhatApp开发实战(十三)
    微服务平台技术架构
    Istio 流量劫持过程
    Istio 组件常用端口
  • 原文地址:https://www.cnblogs.com/wanghaokun/p/11313887.html
Copyright © 2011-2022 走看看