nginx+php-fpm.sock时504,502错误解决办法
小记:
http://nginx.org/en/docs/stream/ngx_stream_core_module.html
2016/04/02 22:28:56
[error] 15308#0: *53 upstream timed out
(110: Connection timed out) while reading response
header from upstream, client: 192.168.130.1, server:
ssl.example.com, request: "POST /phpMyAdmin/import.php HTTP/1.1",
upstream: "fastcgi://unix:/dev/shm/php-fpm.sock", host:
"192.168.130.254", referrer:
"https://192.168.130.254/phpMyAdmin/db_sql.php?db=isfdb&token=b9cf017794df498e0cb52518
2016/04/02 22:33:00 [error] 15305#0: *71 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.130.1, server: ssl.example.com, request: "GET /phpMyAdmin/ HTTP/1.1", upstream: "fastcgi://unix:/dev/shm/php-fpm.sock", host: "192.168.130.254"
此里所有同php解析的动态内容全部无法打开,想临时解决,重启php-fpm即可(注意:重启nginx无效),但只治得了一时,于时开始查找解决方案
解决办法
502
的确,504是解决了,但运行一段时间后,又报了502错误
nginx日志
2016/04/02 23:24:55
[error] 18748#0: *35 recv() failed (104:
Connection reset by peer) while reading response header
from upstream, client: 192.168.130.1, server: ssl.example.com,
request: "POST /phpMyAdmin/import.php HTTP/1.1", upstream:
"fastcgi://unix:/dev/shm/php-fpm.sock:", host: "192.168.130.254",
referrer:
"https://192.168.130.254/phpMyAdmin/db_sql.php?db=isfdb&token=231148330c40cfa09b03d52c
php-fpm日志
[02-Apr-2016 23:24:55] WARNING: [pool www] child 18822, script '/usr/local/nginx/html/phpMyAdmin/import.php' (request: "POST /phpMyAdmin/import.php") execution timed out (340.677871 sec), terminating
[02-Apr-2016 23:24:55] WARNING: [pool www] child 18822 exited on signal 15 (SIGTERM) after 396.757450 seconds from start
[02-Apr-2016 23:24:55] NOTICE: [pool www] child 19164 started
从日志上可以看到, 23:24:55的时,php-fpm的子进程18822因为等待了340.677871秒后被强行终止了并重新生成了一个新的子进程19164
但因为自动生成了新子进程,php网页还是可以正常访问的,只是该查询任务被终止了。
解决办法
request_terminate_timeout = 600