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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM