在 CentOS 6.8 x86_64 上安装 nghttp2 最新版及让 curl 具有 http2 特性

简介: 在 CentOS 6.8 x86_64 上安装 nghttp2 最新版及让 curl 具有 http2 特性

nghttp2 是什么?

nghttp2 是一个实现 IETF 官方 HTTP/2 和 HPACK 头压缩算法的 C 库,但不限如此,在 C 库基础上,还实现了 http2 的客户端,服务器,代理服务器,以及压测工具。参见官网链接

http://www.nghttp2.org/

目前最新版本是 1.24.0

https://github.com/nghttp2/nghttp2/releases


网上基本上都是在 Ubuntu 平台上安装 nghttp2,比如,我按照下面的链接在 Ubuntu 16.04.1 LTS 上顺利安装了 nghttp2

http://www.linuxidc.com/Linux/2016-01/127588.htm

 

安装之前的准备

升级 Autoconf 2.63 到 2.69

http://blog.csdn.net/tao_627/article/details/77259591

升级 GCC 4.4.7 到 4.9.2 (通过 devtoolset)

http://blog.csdn.net/tao_627/article/details/77260963

 

安装相关依赖库

sudo yum -y groupinstall "Development Tools"

sudo yum -y install openssl-devel libxml2-devel libev-devel jemalloc-devel python-devel

wget https://c-ares.haxx.se/download/c-ares-1.12.0.tar.gz -O /tmp/c-ares.tar.gz

mkdir -p /tmp/c-ares

tar -zxvf /tmp/c-ares.tar.gz -C /tmp/c-ares --strip-components=1

cd /tmp/c-ares && ./configure --libdir=/usr/lib64

make

sudo make install

wget http://www.digip.org/jansson/releases/jansson-2.9.tar.gz -O /tmp/jansson.tar.gz

mkdir -p /tmp/jansson

tar -zxvf /tmp/jansson.tar.gz -C /tmp/jansson --strip-components=1

cd /tmp/jansson && ./configure --libdir=/usr/lib64

make

make check

sudo make install


下面编译 nghttp2 最新版

wget https://github.com/nghttp2/nghttp2/releases/download/v1.24.0/nghttp2-1.24.0.tar.bz2

tar jxvf nghttp2-1.24.0.tar.bz2

cd nghttp2-1.24.0

./configure

make

make install

这里只是安装的库,在 /usr/local/lib/libnghttp2.so,头文件在 /usr/local/include/nghttp2


更新动态库

vim /etc/ld.so.conf

添加‘/usr/local/lib’

更新配置文件,执行 ldconfig


注意:nghttp2 本身就是一个 http2 的巨大宝库,这里我们仅是简单用到它的动态库。有兴趣的可以继续研究它的其它应用。


下面将 nghttp2 添加进 curl 中,使 curl 带有 HTTP2 特性

从官网下载最新版 curl 源码

wget https://curl.haxx.se/download/curl-7.55.1.tar.bz2

tar jxvf curl-7.55.1.tar.bz2

cd curl-7.55.1

./configure --with-nghttp2=/usr/local --with-ssl

make

make install


必要时修改环境变量

echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf

ldconfig

更新动态库


遇到的问题

在源码编译 curl 时,执行 configure 命令遇到

checking run-time libs availability... failed

configure: error: one or more libs available at link-time are not available run-time. Libs used at link-time: -lnghttp2   -lssl -lcrypto -lssl -lcrypto   -lz -lrt

解决方法

刚才安装的动态库没有刷新到系统中,导致编译 curl 时没有找到

vim /etc/ld.so.conf

添加‘/usr/local/lib’

更新配置文件,执行 ldconfig

查找下面的库是否已经找到

ldconfig -p | grep --color libnghttp2

验证

查看 curl 版本时会发布特性中会增加 HTTP2 功能支持。此时 –http2 参数就可以正常使用了:

测试 curl with http2

我们再使用如下命令测试

curl --http2 -I https://nghttp2.org/

curl --http2 -vo test.out https://nghttp2.org/

我们可以看到详细的交互信息

相关文章
|
8天前
|
Unix Linux 开发工具
centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】
本文详细介绍了如何在官网下载CentOS 8以及在VMware Workstation Pro 16虚拟机上安装CentOS 8的步骤,包括可能出现的问题和解决方案,如vcpu-0错误的处理方法。
centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】
|
9天前
|
消息中间件 Linux
centos7安装rabbitmq
centos7安装rabbitmq
|
8天前
|
Linux 虚拟化 Windows
完美解决:重新安装VMware Tools灰色。以及共享文件夹的创建(centos8)
这篇文章提供了解决VMware Tools无法重新安装(显示为灰色)问题的步骤,并介绍了如何在CentOS 8上创建和配置VMware共享文件夹。
完美解决:重新安装VMware Tools灰色。以及共享文件夹的创建(centos8)
|
9天前
|
Docker 容器
centos7.3之安装docker
centos7.3之安装docker
|
5天前
|
缓存 Linux 开发工具
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
CentOS7 安装KDE报错的解决方法:Loaded plugins:fastestmirror,langpacks There is no installed group.
13 0
|
5天前
|
安全 测试技术 Linux
CentOS7 安装vulhub漏洞测试环境
CentOS7 安装vulhub漏洞测试环境
11 0
|
8天前
|
Linux
centos 安装etcd|待优化
centos 安装etcd|待优化
|
10天前
|
Linux 网络安全 Python
linux centos上安装python3.11.x详细完整教程
这篇文章提供了在CentOS系统上安装Python 3.11.x版本的详细步骤,包括下载、解压、安装依赖、编译配置、解决常见错误以及版本验证。
80 1
linux centos上安装python3.11.x详细完整教程
|
2月前
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
2月前
|
弹性计算 关系型数据库 MySQL
centos7 mysql安装及配置
本文详细介绍了在阿里云服务器ECS上通过yum源安装MySQL 8.0.12的过程,包括更新yum源、下载并安装MySQL源、解决安装过程中可能遇到的问题等步骤。此外,还介绍了如何启动MySQL服务、设置开机自启、配置登录密码、添加远程登录用户以及处理远程连接异常等问题。适合初学者参考,帮助快速搭建MySQL环境。
158 8
centos7 mysql安装及配置

热门文章

最新文章

下一篇
无影云桌面