curl的官网: http://www.city-fan.org/
1、安装repo
rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/rhel6/x86_64/city-fan.org-release-2-1.rhel6.noarch.rpm
3、修改该repo的enable为1
vim /etc/yum.repos.d/city-fan-for-curl.repo
[CityFanforCurl]
name=City Fan Repo
baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel7/x86_64/
enabled=0
gpgcheck=0
4、安装最新的curl
yum update curl --enablerepo=CityFanforCurl -y
5、如果提示缺少依赖 libnghttp2.so.14()(64bit)
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/Packages/l/libnghttp2-1.6.0-1.el6.1.x86_64.rpm
然后重复第4步即可
6、查看curl版本
# curl -V
curl 7.62.0 (x86_64-redhat-linux-gnu) libcurl/7.62.0 NSS/3.36 zlib/1.2.7 libpsl/0.7.0 (+libicu/50.1.2) libssh2/1.8.0 nghttp2/1.31.1
Release-Date: 2018-10-31
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy PSL Metalink
或者源码安装
下载7.63的源码
wget http://curl.haxx.se/download/curl-7.69.1.tar.gz
解压
tar -xvf curl-7.69.1.tar.gz
cd curl.7.69.1
指定安装目录
./configure --prefix=/usr/local/curl
编译安装
sudo make
sudo make install
添加命令的环境变量
export PATH=$PATH:/usr/local/curl/bin
C或者C++调用使用的头文件
#include <curl/curl.h>
复制头文件到系统目录,也可以自己添加
sudo cp -R /usr/local/curl/include/curl /usr/include