分类: Linux
CentOS7.X升级curl工具

curl是命令行下的网络传输客户端工具,支持包Http、Ftp在内的常见网络协议,支持代理,支持Https、证书,支持各种Http方法,在各发行版的Linux和Windows都支持,而且linux默认自带。其底层的C库libcurl也被很多脚本语言包括PHP(cURL)、Perl(Net::Curl,WWW::Curl)、Python(PyCurl)等打包成模块调用,可直接用于Web客户端编程,编写网络爬虫或者其他Web自动工具;
curl-vi.jpg
CentOS7默认的版本比较低7.29,在某些业务场景下需要升级,步骤如下:
1、创建repo文件

vim /etc/yum.repos.d/city-fan.repo
[CityFan]
name=City Fan Repo
baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel$releasever/$basearch/
enabled=1
gpgcheck=0

或者直接安装libcurl源:

rpm -ivh http://mirror.city-fan.org/ftp/contrib/yum-repo/city-fan.org-release-2-1.rhel7.noarch.rpm
需要将/etc/yum.repos.d/city-fan.org.repo文件中的:enabled=0改为enabled=1

2、升级到最新稳定版本:

yum clean all
yum install epel-release -y   #安装epel源
yum upgrade libcurl curl -y

3、查看版本号:

[root@fabrictest /]# curl -V
curl 7.69.1 (x86_64-redhat-linux-gnu) libcurl/7.69.1 NSS/3.44 zlib/1.2.7 libpsl/0.7.0 (+libicu/50.1.2) libssh2/1.9.0 nghttp2/1.31.1
Release-Date: 2020-03-11
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 GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB PSL SPNEGO SSL UnixSockets
[root@fabrictest /]#

已经升级为最新版本了,当然也可以下载源码,编译安装,curl官网下载地址https://curl.haxx.se/download.html
curl更多用法参考:
https://www.ruanyifeng.com/blog/2019/09/curl-reference.html
http://www.ruanyifeng.com/blog/2011/09/curl.html


相关博文:

发表新评论