CentOS手工升级curl记

笔者一台服务器装有 CentOS 7.9 系统,运行 curl -V 查询 curl 的版本是 7.29,这个老版本的 curl 不支持 HTTP/2 协议。为了使 curl 能连接HTTP/2,curl 必须升级到至少7.46.0版本以上。查询 curl的官网得知当前最新版本是 8.8.0,然而再仔细看,适用于 CentOS 系统的却是7.76.1版,

经过一番摸索,CentOS 是可以安装 8.8.0的,需要手动编译才成功,下面记录一下我手工升级的过程:

1. 安装依赖:

bash 复制代码
sudo yum groupinstall -y 'Development Tools'
sudo yum install -y libnghttp2 libnghttp2-devel openssl-devel

2. 下载并安装最新版本的curl:

bash 复制代码
wget https://curl.se/download/curl-8.8.0.zip
unzip curl-8.8.0.zip
cd curl-8.8.0
./configure

运行 ./configure 而不带参数的话,大概率会报错,如:

于是按提示,把这些 --with 开头的参数都加到 ./configure,尝试运行:

bash 复制代码
./configure  --with-amissl  --with-bearssl  --with-gnutls  --with-mbedtls  --with-nss  --with-openssl  --with-rustls  --with-schannel  --with-secure-transport  --with-wolfssl

嗯,报了另一个错:NSS use must be confirmed using --with-nss-deprecated. NSS support will be dropped from curl in August 2022. See docs/DEPRECATE.md

NSS是一个提供网络安全相关服务的库,系统检测到正在尝试使用NSS(Network Security Services)库,而 curl

计划不再支持 NSS 。因此,如确实要使用NSS,就必须通过--with-nss-deprecated 参数显式指定这一点。

好吧,调整一下configure参数:

bash 复制代码
./configure  --with-amissl  --with-bearssl  --with-gnutls  --with-mbedtls  --with-nss  --with-nss-deprecated --with-openssl  --with-rustls  --with-schannel  --with-secure-transport  --with-wolfssl

又来报错:--with-wolfssl but wolfSSL was not found or doesn't work

暂时不用 wolfSSL 的话,就去掉这个参数,再尝试运行:

bash 复制代码
./configure  --with-amissl  --with-bearssl  --with-gnutls  --with-mbedtls  --with-nss  --with-nss-deprecated --with-openssl  --with-rustls  --with-schannel  --with-secure-transport

又是报错:error: --with-rustls was specified but could not find rustls.

再尝试去掉 --with-rustls 参数:

bash 复制代码
./configure  --with-amissl  --with-bearssl  --with-gnutls  --with-mbedtls  --with-nss  --with-nss-deprecated --with-openssl  --with-schannel  --with-secure-transport

这样,编译过程开始有了进展,不再报错。

编译成功了,但是从上面截图的编译结果看来,倒数第6行显示:HTTP2: No (--with-nghttp2, --with-hyper),如果要启用 HTTP/2,必须要再加多 --with-nghttp2, --with-hyper 参数,再次编译。

bash 复制代码
./configure  --with-amissl  --with-bearssl  --with-gnutls  --with-mbedtls  --with-nss  --with-nss-deprecated --with-openssl  --with-schannel  --with-secure-transport  --with-nghttp2  --with-hyper

编译如果没有报错,就应该出现下图的样子,HTTP2已经是 enabled 的状态。

3. 收尾工作

bash 复制代码
make
make install
sudo ldconfig

4. 确认curl版本和HTTP/2支持:

bash 复制代码
curl -V

输出应包括类似以下内容:

恭喜贺喜,CentOS 可以破格用上最新版 curl 了。。

相关推荐
likfishdn9 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean29 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=31 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
陆沙1 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
北京耐用通信1 小时前
航空装配自动化神器Ethercat转profient网关搭配机器人精准控制
运维·机器人·自动化
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构