php中curl不支持https的解决办法

简介: 在php程序中使用curl去访问https站点时,报错:Protocol https not supported or disabled in libcurl 该错误信息表示php当时编译时使用的curl库不支持https, 验证方法为你的curl安装目录/bin/curl  -V  显示如下:Pr...

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

该错误信息表示php当时编译时使用的curl库不支持https, 验证方法为
你的curl安装目录/bin/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安装目录

目录
相关文章
|
4月前
|
JSON PHP 数据格式
PHP curl方法封装
PHP curl方法封装
31 0
|
1月前
|
PHP 数据格式
PHP 中的CURL 模拟表单的post提交
PHP 中的CURL 模拟表单的post提交
16 0
|
2月前
|
前端开发 应用服务中间件 网络安全
在Apache上http强制跳转到https无效的解决办法
在Apache上http强制跳转到https无效的解决办法
|
6月前
|
Cloud Native Go API
猫头虎解析:深入浅出cURL命令和HTTP请求
猫头虎解析:深入浅出cURL命令和HTTP请求
90 0
|
6月前
|
Cloud Native Go API
使用 cURL 发送 HTTP 请求: 深入探讨与示例
使用 cURL 发送 HTTP 请求: 深入探讨与示例
166 0
|
8月前
|
JSON PHP 数据格式
PHP curl方法封装
PHP curl方法封装
65 0
|
9月前
|
网络协议 C++ Docker
Docker pull拉取镜像报错“Error response from daemon: Get "https://registry-1.docker.io/v2”解决办法
Docker pull拉取镜像报错“Error response from daemon: Get "https://registry-1.docker.io/v2”解决办法
2763 0
|
9月前
|
PHP
php函数file_get_contents无法获取到https链接内容问题使用curl的解决方案
php函数file_get_contents无法获取到https链接内容问题使用curl的解决方案
111 0
|
9月前
|
JSON API PHP
漏刻有时API接口实战开发系列(6):PHP开发API接口离不开的curl函数封装
漏刻有时API接口实战开发系列(6):PHP开发API接口离不开的curl函数封装
54 0