lnmp环境,一键安装,上面只跑了一个wordpress,压力也不大,每天几百个pv,但是基本五六天就会504,重启后又正常.
忍不住了,看了一下日志
大量php-fpm segfault错误
kernel: [4383249.904122] php-fpm[29952]: segfault at 0 ip 00000000008213e0 sp 00007ffe2821e098 error 6 in php-fpm[400000+7b9000]
网上查问题,说有可能是php-fpm的backlog设置-1的问题
[global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www-data listen.group = www-data listen.mode = 0666 user = www-data group = www-data pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 6 request_terminate_timeout = 100 request_slowlog_timeout = 0 slowlog = var/log/slow.log
看了一下自己的配置,果断改成1024
listen.backlog = 1024
其实还有个参数可以添加
pm.max_requests = 200
一个php进程响应多少个请求自动退出,用来防止内存泄露问题
转载请注明: 转自Rainbird的个人博客 本文链接: Linux|lnmp运行时间久了504 bad gateway