Protocol https not supported or disabled in libcurl解决方法

时间:12-10-24 栏目:问题及解决 作者:admin 评论:2 点击: 40,694 次

在php程序中使用curl去访问https站点时,报错:
Protocol https not supported or disabled in libcurl

该错误信息表示php当时编译时使用的curl库不支持https, 验证方法为
你的curl安装目录/bin/curl  -V  或curl  -V
显示如下:
Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp
这表示curl是不支持 https的

为了支持https,需要下载源码包,重新编译curl

tar zxvf curl-7.24.0.tar.gz
cd  curl-7.24.0
./configure --prefix=/usr/local/services/curl-7.24.0 --with-ssl=/usr/local/services/openssl-0.9.8a
#请注意,这里一定要使用 --with-ssl 参数,前提是你已经安装了openssl-0.9.8a (建议安装0.9.8a 测试过0.9.7i有些bug)
该步骤执行结束后,一定要观察仔细,是否有这行
SSL support:     enabled (OpenSSL)
如果你的是
SSL support:     no
那就是说,你的curl依旧没有支持https

make  &&  make install
在make的时候,也许你会遇到这样的错误:
`a local symbol' can not be used when making a shared object; recompile with -fPIC
libssl.a: could not read symbols: Bad value
解决办法,请参考http://mylinux.5d6d.net/viewthread.php?tid=1013
安装完成后,再次运行
curl安装目录/bin/curl -V
结果为
Protocols: dict file ftp gopher http https imap pop3 rtsp smtp telnet tftp
这说明已经支持了https

剩下的就是重新编译php, 当然相应的支持curl的参数为  --with-curl=你的curl安装目录

然后使用:php -i |grep "curl"查看。

解决方法二:

使用以下代码代替CURL函数:

				    $context = array();   

					if (is_array($post))   
					{   
						ksort($post);   

						$context['http'] = array   
						(   
							'method' => 'POST',   
							'content' => http_build_query($post, '', '&'), 
							'header' => "Content-Type: application/x-www-form-urlencoded\r\n" 

						);   
					}   

					$content = file_get_contents($surl, false, stream_context_create($context));

声明: 本文由( admin )原创编译,转载请保留链接: Protocol https not supported or disabled in libcurl解决方法

Protocol https not supported or disabled in libcurl解决方法:目前有2 条留言

  1. 沙发
    zhongyc:

    解决办法的链接打不开,是啥呢,求解,我邮箱:[email protected]

    2013-07-12 7:38 pm [回复]
    • birdzhang:

      +1

      2014-07-31 10:00 am [回复]

发表评论


------====== 本站公告 ======------
联系信息:
电话:19970108113(微信同号) QQ:3142401606
支付宝:https://me.alipay.com/lxq73061
相关插件程序等信息均会在站内发布,敬请关注。

读者排行