nginx下php頻繁卡死502

解決:[WARNING] fpm_children_bury(), line 215: child 2736 (pool default) exited on signal 15 SIGTERM after 59.588363 seconds from start

試用Nginx + PHP FastCGI 作WEB服務器,運行了幾個月的時間,煩惱的是常常碰到Nginx 502 Bad Gateway 這個問題。
參考了不少修改辦法,這個502的問題一直存在,今天打算重裝PHP FastCGI到PHP的安裝目錄裏一看,發現PHP的日誌文件已經有幾十M的大小,打開一看,結果基本所有都是一下的錯誤:
 
Jan 11 08:54:01.164292 [NOTICE] fpm_children_make(), line 352: child 10088 (pool default) started
Jan 11 08:54:01.164325 [WARNING] fpm_children_bury(), line 215: child 7985 (pool default) exited on signal 15 SIGTERM after 63.778601 seconds from start
Jan 11 08:54:01.165485 [NOTICE] fpm_children_make(), line 352: child 10089 (pool default) started
Jan 11 08:54:01.165514 [WARNING] fpm_children_bury(), line 215: child 7999 (pool default) exited on signal 15 SIGTERM after 60.297326 seconds from start
Jan 11 08:54:01.166696 [NOTICE] fpm_children_make(), line 352: child 10090 (pool default) started
Jan 11 08:54:01.166727 [WARNING] fpm_children_bury(), line 215: child 8000 (pool default) exited on signal 15 SIGTERM after 60.296946 seconds from start
Jan 11 08:54:01.167855 [NOTICE] fpm_children_make(), line 352: child 10091 (pool default) started
Jan 12 04:00:50.443884 [NOTICE] fpm_children_make(), line 352: child 10127 (pool default) started
Jan 12 04:00:50.443917 [NOTICE] fpm_event_loop(), line 107: libevent: entering main loop
Jan 12 12:05:08.425141 [WARNING] fpm_request_check_timed_out(), line 158: child 10120, script '/home/htdocs/www/index.php' (pool default) execution timed out (30.051306 sec), terminating
 
 
查過網上的資源,基本都是認爲是php線程打開文件句柄受限致使的錯誤。具體的解決的辦法以下:
 
一、提高服務器的文件句柄打開打開
/etc/security/limits.conf : (增長)
*    soft    nofile    51200
*    hard    nofile    51200
# vi /etc/security/limits.conf 加上
* soft nofile 51200
* hard nofile 51200
 
二、提高nginx的進程文件打開數
 
nginx.conf : worker_rlimit_nofile 51200;
 
三、修改php-fpm.conf文件,主要須要修改2處
 
命令 ulimit -n 查看限制的打開文件數,php-fpm.conf 中的選項rlimit_files 確保和此數值一致。
 
 <value name="max_requests">10240</value>
 
<value name="rlimit_files">51200</value>
 
四、
# vi /etc/sysctl.conf 
底部添加
fs.file-max=51200

完成以上修改,重啓PHP,警告信息再也沒了。
 
世界今後安寧,502 Bad Gateway 沒有了。
相關文章
相關標籤/搜索