Curl简介
Curl是一个利用URL语法在命令行下工作的文件传输工具,1997年首次发行。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称Curl为下载工具。Curl还包含了用于程序开发的libcurl。
Curl支持的通信协议有FTP、FTPS、HTTP、HTTPS、TFTP、SFTP、Gopher、SCP、Telnet、DICT、FILE、LDAP、LDAPS、IMAP、POP3、SMTP和RTSP。
Curl还支持SSL认证、HTTP POST、HTTP PUT、FTP上传, HTTP form based upload、proxies、HTTP/2、cookies、用户名 密码认证(Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate and Kerberos)、file transfer resume、proxy tunneling。
说明:
由于业务需要,服务器上的Curl版本太老了,有漏洞,于是抽点时间升级最新版本,确保服务器间通信安全。
Yum安装
1、安装repo
[root@localhost ~]# 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
[root@localhost ~]# vim /etc/yum.repos.d/city-fan.org.repo
代码语言:javascript复制[city-fan.org]name=city-fan.org repository for Red Hat Enterprise Linux (and clones) $releasever ($basearch)#baseurl=http://mirror.city-fan.org/ftp/contrib/yum-repo/rhel$releasever/$basearchmirrorlist=http://mirror.city-fan.org/ftp/contrib/yum-repo/mirrorlist-rhel$releaseverenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-city-fan.org [city-fan.org-debuginfo]name=city-fan.org debuginfo repository for Red Hat Enterprise Linux (and clones) $releasever ($basearch)#baseurl=http://www.city-fan.org/ftp/contrib-debug/rhel$releasever/$basearchmirrorlist=http://www.city-fan.org/ftp/contrib-debug/mirrorlist-rhel$releaseverenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-city-fan.org [city-fan.org-source]name=city-fan.org source repository for Red Hat Enterprise Linux (and clones) $releasever#baseurl=http://mirror.city-fan.org/ftp/contrib/yum-repo/rhel$releasever/sourcemirrorlist=http://mirror.city-fan.org/ftp/contrib/yum-repo/source-mirrorlist-rhel$releaseverenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-city-fan.org
4、安装依赖
[root@localhost ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/Packages/l/libnghttp2-1.6.0-1.el6.1.x86_64.rpm
5、安装最新的curl
[root@localhost ~]# yum update curl --enablerepo=city-fan.org -y
6、查看curl版本
[root@localhost ~]# curl -V
curl 7.70.0 (x86_64-redhat-linux-gnu) libcurl/7.70.0 NSS/3.44 zlib/1.2.7 libpsl/0.7.0 ( libicu/50.1.2) libssh2/1.9.0 nghttp2/
1.6.0Release-Date: 2020-04-29
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tft
p Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB PSL SPNEGO SSL UnixSockets
源码安装
官网下载地址:https://curl.haxx.se/download.html
1、下载源码包
[root@localhost ~]# wget https://curl.haxx.se/download/curl-7.70.0.tar.gz
2、解压源码包
[root@localhost ~]# tar xf curl-7.70.0.tar.gz
3、编译及安装
[root@localhost ~]# cd curl-7.70.0
[root@localhost curl-7.70.0]# ./configure --prefix=/usr/local/curl
[root@localhost curl-7.70.0]# make && make install
4、添加环境变量
[root@localhost curl-7.70.0]# vim /etc/profile
# 添加以下内容
代码语言:javascript复制export PATH=$PATH:/usr/local/curl/bin
# 加载环境变量
[root@localhost curl-7.70.0]# source /etc/profile
5、查看版本
[root@localhost curl-7.70.0]# curl -V
curl 7.70.0 (x86_64-redhat-linux-gnu) libcurl/7.70.0 NSS/3.44 zlib/1.2.7 libpsl/0.7.0 ( libicu/50.1.2) libssh2/1.9.0 nghttp2/
1.6.0Release-Date: 2020-04-29
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tft
p Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB PSL SPNEGO SSL UnixSockets