解决curl获取https时显示502的问题【ngnix下】
[i=s] 本帖最后由 skypirate 于 2017-3-15 19:37 编辑 [/i]环境是php5.2.17、lnamp,访问http没问题,访问https时就出现502,以前解决过一次,但没记录步骤,重装系统后又出现了这个问题,直接懵圈。升级到php5.3可以解决这个问题,但以前的代码是用zend加密的,只能在5.2.17下运行,对接的API又必须访问https,只能又废了一下午的时间找资料,记录下来,以备忘!
[color=Blue]编译安装curl,重新编译php,使php的curl模块支持https[/color]。
具体步骤:
1、下载curl
[font=Tahoma, Helvetica, SimSun, sans-serif][size=3]wget dl2.admin5.com/php/curl-7.37.1.tar.gz[/size][/font]
[font=Tahoma, Helvetica, SimSun, sans-serif][size=3]tar zxvf curl-7.37.1.tar.gz[/size][/font][size=12px] #下载[/size]
2、安装curl
[font=Tahoma, Helvetica, SimSun, sans-serif]cd curl-7.37.1[/font]
[size=3]./configure --prefix=/usr/local/curl --with-gssapi --enable-tls-srp --with-libmetalink #配置[/size]
make #编译
make install #安装
3、重新编译php
wget -c http://dl.wdlinux.cn:5180/soft/php-5.2.17.tar.gz
tar zxvf php-5.2.17.tar.gz
cd php-5.2.17
./configure --prefix=/www/wdlinux/php-5.2.17 --with-config-file-path=/www/wdlinux/etc --with-mysql=/www/wdlinux/mysql --with-iconv=/usr --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-inline-optimization --with-curl-dir=/usr/local/curl --enable-mbregex --enable-mbstring --with-mcrypt=/usr --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-ftp --with-apxs2=/www/wdlinux/apache/bin/apxs
make
make install
rm -f /www/wdlinx/php
ln -s /www/wdlinux/php-5.2.17 /www/wdlinux/php
service httpd restart
make #编译
make install #安装
4、重启apache使设置生效
service httpd restart #重启
故障解决!
5、测试
以下代码,保存为phpinfo.php
<?php
phpinfo();
?>
上传到网站目录,查找curl,如下图所示,说明安装成功!
[attach]7140[/attach]
参考链接:
http://www.wdlinux.cn/bbs/viewthread.php?tid=38067&highlight=qq
页:
[1]