LNMP环境出现502 Bad Gateway报错

环境:

centos 6.9
php-5.2.14
nginx 1.15

故障现象:

配置好LNMP环境后,phpinfo能够正常打开

1.web访问HTTPS异常
站点页面访问正常,但是跳转https时,出现502 Bad Gateway

2、php-fpm log
fpm_children_bury(), line 215: child 8460 (pool default) exited on signal 11 SIGSEGV (core dumped)

3、nginx error log
2018/09/21 15:52:29 [error] 2463#0: *36 recv() failed (104: Connection reset by peer) while reading response header from upstream

故障排查

在centos 6.9的系统里面的curl支持的https是nss版本的,而不是openssl的,
因为php环境原因,必须使用openssl

解决方法:

根据链接里面说的,去官网下载了一个最新版本(curl-7.28.1.tar.gz)的curl,来进行源码编译。
编译的依赖,openssl和openssl-devel。
编译方法和其他软件类似,步骤如下:
去到源码目录:curl-7.28.1
./configure --without-nss --with-ssl && make &&make install 即可完成编译。

1、系统的curl生成

wget http://curl.haxx.se/download/curl-7.35.0.tar.gz
tar -zxvf curl-7.35.0.tar.gz
cd curl-7.35.0.tar.gz

cd /www/src/curl-7.39.0
./configure --prefix=/usr/local/curl --without-nss --with-ssl
make && make install

备份默认的curl二进制文件
sudo mv /usr/bin/curl /usr/bin/curl.bak
然后做一个新的curl软链
sudo ln -s /usr/local/curl/bin/curl /usr/bin/curl

然后再curl --version确认是否已经是openssl的版本

2、生成curl.so

cd /www/src/lanmp/php-5.2.17/ext/curl
/www/wdlinux/php/bin/phpize
./configure --with-php-config=/www/wdlinux/php/bin/php-config --with-curl=/usr/local/curl/

make && make install

3、重新编译php(php.ini找出原先的配置参数,复制,去掉with-curl,然后编译

cd /www/src/lanmp/php-5.2.17/

./configure '--prefix=/www/wdlinux/apache_php-5.2.17' '--with-config-file-path=/www/wdlinux/apache_php-5.2.17/etc' '--with-mysql=/www/wdlinux/mysql' '--with-iconv=/usr' '--with-mysqli=/www/wdlinux/mysql/bin/mysql_config' '--with-pdo-mysql=/www/wdlinux/mysql' '--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' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-ftp' '--enable-bcmath' '--enable-exif' '--enable-sockets' '--enable-zip' '--with-apxs2=/www/wdlinux/apache/bin/apxs'

4、编译完后,在php.ini里增加

extension=curl.so

重启php-fpm即可

本问题感谢:https://www.cnblogs.com/showker/p/4706271.html Showker笔记支持

猜你喜欢

转载自blog.51cto.com/7603402/2178807