我最近将我的magento从1.5升级到1.9,当我将某个产品添加到购物篮时,我开始收到此错误:502 Bad Gateway
var / log /文件夹中没有日志条目:
所以,我查看了我的Nginx错误,并在Nginx-errors.log中找到了以下条目:
2015/04/09 10:58:03 [error] 15208#0: *3 recv() Failed (104: Connection reset by peer) while reading response header from upstream,client: 46.xxx.xxx.xxx,server: dev.my-domain.co.uk,request: "POST /checkout/cart/add/uenc/aHR0cDovL2Rldi5zYWx2ZW8uY28udWsvdGludGktYmF0aC1wYWludGluZy1zb2FwLTcwbWwuaHRtbD9fX19TSUQ9VQ,/product/15066/form_key/eYLc3lQ35BSrk6Pa/ HTTP/1.1",upstream: "fastcgi://unix:/var/run/PHP-fcgi-www-data.sock:",host: "dev.my-domain.co.uk",referrer: "http://dev.my-domain.co.uk/tinti-bath-painting-soap-70ml.html" 2015/04/09 11:04:42 [error] 15208#0: *13 recv() Failed (104: Connection reset by peer) while reading response header from upstream,referrer: "http://dev.my-domain.co.uk/tinti-bath-painting-soap-70ml.html" 2015/04/09 11:05:03 [error] 15208#0: *16 recv() Failed (104: Connection reset by peer) while reading response header from upstream,referrer: "http://dev.my-domain.co.uk/tinti-bath-painting-soap-70ml.html" 2015/04/09 11:12:07 [error] 15273#0: *1 recv() Failed (104: Connection reset by peer) while reading response header from upstream,referrer: "http://dev.my-domain.co.uk/tinti-bath-painting-soap-70ml.html"
我在自定义LEMP堆栈上安装了magento,以下是配置:
> nginx.conf
> fastcgi_params
> dev.my-domain.co.uk.conf(Nginx vhost)
> www-data.conf(PHP-fpm pool config)
仅当我在升级的magento中将特定产品添加到购物篮时才会出现此错误,并且每次发生错误时,我都可以在public_html文件夹中看到core.XXXXX文件(大约350mb).
知道为什么我的PHP-fpm会像这样崩溃吗?我怎样才能找到原因并加以解决?
这是我运行dmesg命令时Linux(CentOS)服务器上的最后一个条目:
PHP-fpm[14862]: segfault at 7fff38236ff8 ip 00000000005c02ba sp 00007fff38237000 error 6 in PHP-fpm[400000+325000] PHP-fpm[15022]: segfault at 7fff38351ff0 ip 00000000005bf6e5 sp 00007fff38351fb0 error 6 in PHP-fpm[400000+325000] PHP-fpm[15021]: segfault at 7fff38351ff0 ip 00000000005bf6e5 sp 00007fff38351fb0 error 6 in PHP-fpm[400000+325000] PHP-fpm[15156]: segfault at 7fff38351ff0 ip 00000000005bf6e5 sp 00007fff38351fb0 error 6 in PHP-fpm[400000+325000] PHP-fpm[15024]: segfault at 7fff38351ff0 ip 00000000005bf6e5 sp 00007fff38351fb0 error 6 in PHP-fpm[400000+325000] PHP-fpm[15223]: segfault at 7fff8d1d5fd8 ip 00000000005c02ba sp 00007fff8d1d5fe0 error 6 in PHP-fpm[400000+325000] PHP-fpm[15222]: segfault at 7fff8d1d5fd8 ip 00000000005c02ba sp 00007fff8d1d5fe0 error 6 in PHP-fpm[400000+325000] PHP-fpm[15225]: segfault at 7fff8d1d5fd8 ip 00000000005c02ba sp 00007fff8d1d5fe0 error 6 in PHP-fpm[400000+325000] PHP-fpm[15227]: segfault at 7fff8d1d5fd8 ip 00000000005c02ba sp 00007fff8d1d5fe0 error 6 in PHP-fpm[400000+325000] PHP-fpm[15362]: segfault at 7fff3118afd0 ip 00000000005c0ace sp 00007fff3118afa0 error 6 in PHP-fpm[400000+325000]
我用gdb分析了核心转储,这是我在前两帧中看到的:http://pastebin.com/raw.php?i=aPvB1sWv(对我来说没什么意义)……
解决方法
当服务器资源不足时,通常会发生这样的错误,假设您正在运行`PHP5-fpm的最新稳定版本:
>检查PHP5-fpm是否有足够的内存(没有oom-killer杀死进程)
>磁盘上有足够的空间
>确保检查服务器上的打开文件限制.你特别感兴趣的是硬限制(-Hn):
$ulimit -Hn 4096 $ulimit -Sn 1024
sysctl fs.file-nr fs.file-nr = 1440 0 790328
现代服务器能够处理许多文件,通常ulimits设置为不必要的低值.
然后检查Nginx.conf,开头有类似的东西:
worker_processes 4; events { worker_connections 1024; }
如果您代理每个连接的请求,则需要2个文件句柄.这意味着如果有很多连接,你很快就会达到极限.
Nginx有一个@L_403_5@指令,用于限制每个工作进程打开的文件(顶级指令,如worker_processes 4;):
worker_rlimit_nofile 1024;
只需进行数学运算并计算在使用所有连接时需要打开的文件描述符的数量(有点极端情况).还要考虑在该服务器上运行的所有其他服务.什么时候