这是第二次遇到该问题了,上次解决后由于没有记录,结果此次遇到后又得从新查找解决方法。记忆力严重减退了啊,仍是要保持边学边记录的习惯
php
网站在正常运行时是没有问题的,可是在使用xdebug进行远程调试时,可能会由于单步调试,查看内存,分析数据等状况耗时太长,致使页面出现502。这时候虽然还能够进行单步调试,可是已经看不到内存数据了(由于进程已经结束)。因而又得从新调试,调试过程当中仍然没法避免调试时间过长,页面继续502。。。nginx
观察了下页面502的响应时长,发现每次都是30s过一点。猜想多是服务器的配置文件设置了30s的超时时间,因而依次查找了nginx.conf,php-fpm.conf,php.ini(这三个文件原先使用默认配置)。发现nginx.conf里没有30s的配置,php-fpm.conf和php.ini里都有30s的配置。最后实验得出结论:只须要修改php-fpm.conf的request_terminate_timeout值就能够解决超时页面显示502的问题。服务器
php-fpm.conf配置说明php-fpm
; 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 = 0
网站
php.in配置说明spa
; 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 = 30
.net