curl 是一个强大的命令行工具,它可以模拟浏览器发送HTTP请求的功能。它支持多种协议,如HTTP、HTTPS、FTP等,并且可以用来获取或发送数据到服务器,包括下载文件、提交表单数据、处理cookies、验证证书、模拟不同的用户代理等。 与Web浏览器相比,curl 的优势在于其简洁的命令行界面和灵活的脚本化能力。开发者经常使用 curl 来调试API接口、测试服务器响应、批量处理数据以及自动化任务。
查看操作系统信息
[root@localhost ~]# cat /etc/.kyinfo
[dist]
name=Kylin
milestone=Server-V10-GFB-Release-ZF9_01-2204-Build03
arch=arm64
beta=False
time=2023-01-09 11:04:36
dist_id=Kylin-Server-V10-GFB-Release-ZF9_01-2204-Build03-arm64-2023-01-09 11:04:36
[servicekey]
key=0080176
[os]
to=
term=2024-05-16
2.下载源码软件包
[root@localhost src]# wget https://github.com/curl/curl/releases/download/curl-8_10_1/curl-8.10.1.tar.gz
解压软件包
[root@localhost src]# tar -zxvf curl-8.10.1.tar.gz
查看解压后的软件包
[root@localhost src]# cd curl-8.10.1/
[root@localhost curl-8.10.1]# ls
acinclude.m4 CMake config.sub curl-config.in include ltmain.sh Makefile.in projects src
aclocal.m4 CMakeLists.txt configure depcomp install-sh m4 missing README tests
buildconf.bat compile configure.ac Dockerfile lib Makefile.am packages RELEASE-NOTES winbuild
CHANGES.md config.guess COPYING docs libcurl.pc.in Makefile.dist plan9 scripts
配置
[root@localhost curl-8.10.1]# ./configure --prefix=/usr/local/curl --with-ssl=/usr/local/openssl
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether make supports nested variables... yes
checking whether to enable debug build options... no
checking whether to enable compiler optimizer... (assumed) yes
checking whether to enable strict compiler warnings... no
checking whether to enable compiler warnings as errors... no
checking whether to enable curl debug memory tracking... no
checking whether to enable hiding of library internal symbols... yes
checking whether to enable c-ares for DNS lookups... no
checking whether to disable dependency on -lrt... (assumed no)
checking whether to enable HTTPSRR support... no
checking whether to enable ECH support... no
checking for path separator... :
............................................................................
configure: Configured to build curl/libcurl:
Host setup: aarch64-unknown-linux-gnu
Install prefix: /usr/local/curl
Compiler: gcc
CFLAGS: -Werror-implicit-function-declaration -O2 -Wno-system-headers -pthread
CFLAGS extras:
CPPFLAGS: -isystem /usr/local/openssl/include
LDFLAGS: -L/usr/local/openssl/lib
LIBS: -lpsl -lssl -lcrypto -lssl -lcrypto -lbrotlidec -lz
curl version: 8.10.1
SSL: enabled (OpenSSL v3+)
SSH: no (--with-{libssh,libssh2})
zlib: enabled
brotli: enabled (libbrotlidec)
zstd: no (--with-zstd)
GSS-API: no (--with-gssapi)
GSASL: no (libgsasl not found)
TLS-SRP: enabled
resolver: POSIX threaded
IPv6: enabled
Unix sockets: enabled
IDN: no (--with-{libidn2,winidn})
Build docs: enabled (--disable-docs)
Build libcurl: Shared=yes, Static=yes
Built-in manual: enabled
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
Code coverage: disabled
SSPI: no (--enable-sspi)
ca cert bundle: /etc/pki/tls/certs/ca-bundle.crt
ca cert path: no
ca fallback: no
LDAP: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS: no (--enable-ldaps)
RTSP: enabled
RTMP: no (--with-librtmp)
PSL: enabled
Alt-svc: enabled (--disable-alt-svc)
Headers API: enabled (--disable-headers-api)
HSTS: enabled (--disable-hsts)
HTTP1: enabled (internal)
HTTP2: no (--with-nghttp2)
HTTP3: no (--with-ngtcp2 --with-nghttp3, --with-quiche, --with-openssl-quic, --with-msh3)
ECH: no (--enable-ech)
WebSockets: no (--enable-websockets)
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HSTS HTTPS-proxy IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets
编译
[root@localhost curl-8.10.1]# make -j $(nproc)
Making all in lib
make[1]: 进入目录“/usr/local/src/curl-8.10.1/lib”
make all-am
make[2]: 进入目录“/usr/local/src/curl-8.10.1/lib”
CC libcurl_la-altsvc.lo
CC libcurl_la-amigaos.lo
CC libcurl_la-asyn-ares.lo
CC libcurl_la-asyn-thread.lo
CC libcurl_la-base64.lo
CC libcurl_la-bufq.lo
CC libcurl_la-bufref.lo
CC libcurl_la-cf-h1-proxy.lo
CC libcurl_la-cf-h2-proxy.lo
CC libcurl_la-cf-haproxy.lo
CC libcurl_la-conncache.lo
CC libcurl_la-c-hyper.lo
CC libcurl_la-content_encoding.lo
CC libcurl_la-cf-https-connect.lo
CC libcurl_la-cfilters.lo
CC libcurl_la-cf-socket.lo
CC libcurl_la-connect.lo
CC libcurl_la-curl_endian.lo
CC libcurl_la-curl_fnmatch.lo
CC libcurl_la-curl_get_line.lo
CC libcurl_la-curl_des.lo
CC libcurl_la-curl_gethostname.lo
CC libcurl_la-curl_memrchr.lo
CC libcurl_la-cookie.lo
CC libcurl_la-curl_addrinfo.lo
CC libcurl_la-curl_gssapi.lo
CC libcurl_la-curl_threads.lo
CC libcurl_la-curl_ntlm_core.lo
CC libcurl_la-curl_multibyte.lo
CC libcurl_la-curl_sspi.lo
CC libcurl_la-curl_rtmp.lo
CC libcurl_la-cw-out.lo
CC libcurl_la-doh.lo
CC libcurl_la-dynhds.lo
CC libcurl_la-curl_sasl.lo
CC libcurl_la-curl_path.lo
CC libcurl_la-dict.lo
CC libcurl_la-dynbuf.lo
CC libcurl_la-curl_range.lo
CC libcurl_la-curl_sha512_256.lo
CC libcurl_la-curl_trc.lo
CC libcurl_la-dllmain.lo
CC libcurl_la-easygetopt.lo
CC libcurl_la-fileinfo.lo
CC libcurl_la-fopen.lo
CC libcurl_la-easy.lo
CC libcurl_la-ftp.lo
CC libcurl_la-ftplistparser.lo
CC libcurl_la-escape.lo
CC libcurl_la-getenv.lo
CC libcurl_la-formdata.lo
CC libcurl_la-gopher.lo
CC libcurl_la-hostasyn.lo
CC libcurl_la-hostip.lo
CC libcurl_la-hostip4.lo
CC libcurl_la-file.lo
CC libcurl_la-easyoptions.lo
CC libcurl_la-getinfo.lo
CC libcurl_la-hsts.lo
CC libcurl_la-hmac.lo
CC libcurl_la-http.lo
CC libcurl_la-http1.lo
CC libcurl_la-hostip6.lo
...................................................................................
make[1]: 离开目录“/usr/local/src/curl-8.10.1/src”
Making all in scripts
make[1]: 进入目录“/usr/local/src/curl-8.10.1/scripts”
make[1]: 对“all”无需做任何事。
make[1]: 离开目录“/usr/local/src/curl-8.10.1/scripts”
make[1]: 进入目录“/usr/local/src/curl-8.10.1”
make[1]: 对“all-am”无需做任何事。
make[1]: 离开目录“/usr/local/src/curl-8.10.1”
安装
[root@localhost curl-8.10.1]# make install
Making install in lib
make[1]: 进入目录“/usr/local/src/curl-8.10.1/lib”
make[2]: 进入目录“/usr/local/src/curl-8.10.1/lib”
/bin/mkdir -p '/usr/local/curl/lib'
/bin/sh ../libtool --mode=install /bin/install -c libcurl.la '/usr/local/curl/lib'
libtool: install: /bin/install -c .libs/libcurl.so.4.8.0 /usr/local/curl/lib/libcurl.so.4.8.0
libtool: install: (cd /usr/local/curl/lib && { ln -s -f libcurl.so.4.8.0 libcurl.so.4 || { rm -f libcurl.so.4 && ln -s libcurl.so.4.8.0 libcurl.so.4; }; })
libtool: install: (cd /usr/local/curl/lib && { ln -s -f libcurl.so.4.8.0 libcurl.so || { rm -f libcurl.so && ln -s libcurl.so.4.8.0 libcurl.so; }; })
libtool: install: /bin/install -c .libs/libcurl.lai /usr/local/curl/lib/libcurl.la
libtool: install: /bin/install -c .libs/libcurl.a /usr/local/curl/lib/libcurl.a
libtool: install: chmod 644 /usr/local/curl/lib/libcurl.a
libtool: install: ranlib /usr/local/curl/lib/libcurl.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/openssh/sbin:/usr/local/erlang//bin:/usr/local/go/bin:/root/go/bin:/usr/local/livekit/bin:/usr/local/apache-maven-3.9.6//bin:/usr/local/minio//bin:/usr/local/mysql//bin:/usr/local/node/bin:/usr/local/pnpm/bin:/usr/local/rabbitmq//sbin:/root/bin:/sbin" ldconfig -n /usr/local/curl/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/curl/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
......................................................................................
make[6]: 离开目录“/usr/local/src/curl-8.10.1/docs/libcurl”
make[5]: 离开目录“/usr/local/src/curl-8.10.1/docs/libcurl”
make[4]: 离开目录“/usr/local/src/curl-8.10.1/docs/libcurl”
make[3]: 离开目录“/usr/local/src/curl-8.10.1”
make[2]: 离开目录“/usr/local/src/curl-8.10.1”
make[1]: 离开目录“/usr/local/src/curl-8.10.1”
查看版本
[root@localhost bin]# ./curl --version
curl 8.10.1 (aarch64-unknown-linux-gnu) libcurl/8.10.1 OpenSSL/3.4.0 zlib/1.2.11 brotli/1.0.7 zstd/1.3.6 libpsl/0.20.2
Release-Date: 2024-09-18
Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli HSTS HTTPS-proxy IPv6 Largefile libz NTLM PSL SSL threadsafe TLS-SRP UnixSockets zstd