编译支持http2的curl
2015 年 10 月 17 日 编译支持http2的curl有3条评论
ubuntu 14.04 在运行
curl https://www.xdty.org -v --http2.0
时提示
curl: (1) Unsupported protocol。
使用
curl --version
命令得到
curl 7.35.0 (x86_64-pc-linux-gnu) libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP
可见不支持 http2。需要重新编译支持 http2 的 libcurl。
1. 安装依赖
apt-get install make binutils autoconf automake autotools-dev libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libssh2-1-dev libxml2-dev libev-dev libevent-dev libjansson-dev libjemalloc-dev cython python3.4-dev python-setuptools
2. 编译安装 spdylay
git clone https://github.com/tatsuhiro-t/spdylay.git
cd spdylay/
autoreconf -i
automake
autoconf
./configure
make
make install
cd ..
cd spdylay/
autoreconf -i
automake
autoconf
./configure
make
make install
cd ..
3. 编译安装 nghttp2
git clone https://github.com/tatsuhiro-t/nghttp2.git
cd nghttp2
autoreconf -i
automake
autoconf
./configure
make
make install
cd nghttp2
autoreconf -i
automake
autoconf
./configure
make
make install
4. 编译安装 curl 和 libcurl
wget http://curl.haxx.se/download/curl-7.45.0.tar.gz
tar xvf curl-7.45.0.tar.gz
cd curl-7.45.0
./configure --with-nghtt2=/usr/local/nghttp2
make
make install
tar xvf curl-7.45.0.tar.gz
cd curl-7.45.0
./configure --with-nghtt2=/usr/local/nghttp2
make
make install
需要增加/usr/local/lib到环境变量中
新建一个 /etc/ld.so.conf.d/local.conf 文件, 添加内容 /usr/local/lib
运行 ldconfig 载入
使用 curl –version 命令查看版本
curl 7.45.0 (x86_64-pc-linux-gnu) libcurl/7.45.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 libssh2/1.4.3 nghttp2/1.0.5-DEV librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets
显示已支持 HTTP2
使用 curl https://www.xdty.org -v –http2 测试 http2
Tags: curl http2 libcurl nghttp2 spdylay ubuntu
评论:3