openresty/nginx升級http2

http2需要https支持,假設你已經有https證書

從源碼編譯安裝openresty

解壓:
tar -xzvf openresty-VERSION.tar.gz
cd openresty-VERSION/
三連:
./configure
make
sudo make install

此時安裝的openresty配置http2會報錯 the "http2" parameter requires ngx_http_v2_module

重新編譯:./configure --with-http_v2_module
編譯完成後make (不要make insall ,會覆蓋安裝)
編譯出的nginx在 openresty-1.13.6.2/build/nginx-1.13.6/objs/
我們之擁替換此二進制文件就好了

nginx -s stop先停止nginx

openresty-1.13.6.2/build/nginx-1.13.6/objs/nginx 複製到/usr/local/openresty/nginx/sbin

不先停止nginx的話會出現 cp: 無法創建普通文件'./nginx': 文本文件忙

然後將listenhttp2配置上啓動nginx應該就可以看到

圖片描述

如果替換了新編譯的nginx二進制文件還是使用http1.1,檢查一下openssl版本和編譯的模塊,openssl版本需大於1.0.1才能支持http2

圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章