广告

本站里的文章大部分经过自行整理与测试

2017年10月28日星期六

Ubuntu - CURL - HTTP1.1 改为 HTTP2

1) 检测 CURL 是用 HTTP 1.1 还是 HTTP 2

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

HTTP/2 200

2) 如果是 HTTP1.1

2.1) 编译工具

$ sudo apt install git g++ make binutils autoconf automake autotools-dev libtool pkg-config
$ sudo apt install zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev 
$ sudo apt install libjansson-dev libjemalloc-dev cython python3-dev python-setuptools

2.2) nghttp2

$ git clone https://github.com/tatsuhiro-t/nghttp2.git
$ cd nghttp2
$ autoreconf -i
$ automake
$ autoconf
$ ./configure
$ make
$ sudo make install

2.3) CURL

$ wget https://curl.haxx.se/download/curl-7.56.1.tar.bz2
$ tar -xvjf curl-7.56.1.tar.bz2
$ cd curl-7.56.1
$ ./configure --with-nghttp2=/usr/local --with-ssl
$ sudo make
$ sudo make install

2.4) 将 /usr/local/lib 写入 /etc/ld.so.conf.d/local.conf

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

2.5) 检测

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

3) 嫌麻烦? 一个脚本, 搞定..

$ wget https://github.com/yomun/linux-init/raw/master/ubuntu/curl-http2.sh
$ sudo bash curl-http2.sh

没有评论:

发表评论