提问三步曲: 提问先看教程/FAQ索引(wdcp,wdcp_v3,一键包)及搜索,会让你更快解决问题
1 提供详细,如系统版本,wdcp版本,软件版本等及错误的详细信息,贴上论坛或截图发论坛
2 做过哪些操作或改动设置等
温馨提示:信息不详,很可能会没人理你!论坛有教程说明的,也可能没人理!因为,你懂的
[教程] 解决nginx 502 bad gateway问题,[方法]重新编译wdcp的fpm-php
最近在把joomla 1.5.18的一个站点从虚拟主机的apache移到另一台VPS主机的nginx上,根据joomla官方提供的nginx rewrite规则修改了nginx的配置,结果的大部分的网页都正常显示,只有一个contact us的页面在发送邮件的时候,遇到错误:nginx 502 bad gateway
系统环境:
CentOS 6.4 86x64
wdcp: wget http://dl.wdlinux.cn:5180/lanmp_laster.tar.gz
0c5d80fd4b28b7049d18275962f1fc09 lanmp_laster.tar.gz
nginx 1.0.15
mysql 5.1.63
php 5.2.17
有2条错误比较引人注意:
tail /www/wdlinux/nginx_php-5.2.17/logs/php-fpm.log
[WARNING] fpm_children_bury(), line 215: child 16523 (pool default) exited on signal 15 SIGTERM after 1868.423609 seconds from start
tail /www/wdlinux/nginx/logs/error.log
[error] 16501#0: *5 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 123.456.789, server: www.shop-yishunbike.com, request: "POST /index.php?option=com_contact&view=contact&id=1&Itemid=210 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "............", referrer: "........................."
用site:()搜索:
site:(wdlinux.cn) recv() failed (104: Connection reset by peer)
谷歌百度对以上错误的搜索结果都是要修改php.ini,php-fpm.conf,nginx.conf等配置,结果都没成功
回过头来好好思考这2个错误提示,nginx的错误应该是由于nginx提交给php-fpm(127.0.0.1:9000)的请求没有得到正确的回复引起的,所以可能是php-fpm的问题。
所以想到重新编译fpm-php,结果成功了
重新编译过程:
参考wdcp中lanmp.sh脚本的安装路径:
./configure --prefix=$IN_DIR/$PHP_DIR --with-config-file-path=$IN_DIR/$PHP_DIR/etc --with-mysql=$IN_DIR/mysql --with-iconv=/usr --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt=/usr --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-ftp --enable-sockets --enable-zip $NV
再参考张宴大哥的那篇nginx文章,运行如下命令:
tar zxf php-5.4.13.tar.gz
cd php-5.4.13
LIBS="-lm -ltermcap -lresolv"DYLD_LIBRARY_PATH="/www/wdlinux/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
LD_LIBRARY_PATH="/www/wdlinux/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
#./configure阶段,在后面加上-n选项不生成配置,仅测试是否能通过,通过的话去掉-n,再运行一次
./configure --prefix=/www/wdlinux/php2 --with-config-file-path=/www/wdlinux/php2/etc --with-mysql=/www/wdlinux/mysql --with-mysqli=/www/wdlinux/mysql/bin/mysql_config --with-mcrypt=/usr --with-iconv-dir=/usr --with-libxml-dir=/usr --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap -n
make ZEND_EXTRA_LIBS='-liconv'
make install
关闭原来的php-fpm
/etc/init.d/php-fpm stop
打开新的php-fpm进程
/www/wdlinux/php2/sbin/php-fpm
打开contact us页面,发送邮件,成功发送 |