国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

升級nginx以支持http2的方法

2024-08-30 12:29:30
字體:
來源:轉載
供稿:網友

本文介紹了升級nginx以支持http2的方法,分享給大家,具體如下:

一鍵升級腳本

https://github.com/whisshe/upHttp2.git

HTTP/2 的優勢

相比 HTTP/1.x,HTTP/2 在底層傳輸做了很大的改動和優化:

  1. HTTP/2 采用二進制格式傳輸數據,而非 HTTP/1.x 的文本格式。二進制格式在協議的解析和優化擴展上帶來更多的優勢和可能。
  2. HTTP/2 對消息頭采用 HPACK 進行壓縮傳輸,能夠節省消息頭占用的網絡的流量。而 HTTP/1.x 每次請求,都會攜帶大量冗余頭信息,浪費了很多帶寬資源。頭壓縮能夠很好的解決該問題。
  3. 多路復用,直白的說就是所有的請求都是通過一個 TCP 連接并發完成。HTTP/1.x 雖然通過 pipeline 也能并發請求,但是多個請求之間的響應會被阻塞的,所以 pipeline  至今也沒有被普及應用,而 HTTP/2 做到了真正的并發請求。同時,流還支持優先級和流量控制。
  4. Server Push:服務端能夠更快的把資源推送給客戶端。例如服務端可以主動把 JS 和 CSS 文件推送給客戶端,而不需要客戶端解析 HTML 再發送這些請求。當客戶端需要的時候,它已經在客戶端了。

升級HTTP2必要條件

  1. 1.10.0版本以上的nginx基于1.0.2以上版本的openssl編譯
  2. 必須支持https

軟件安裝位置

openssl

1、編譯位置
/usr/local/openssl
2、軟鏈接位置
/usr/bin/openssl
/usr/include/openssl

nginx
1、編譯及配置文件位置
/etc/nginx

升級所有游戲服務器的nginx和OpenSSL

升級openssl

1、將舊版本的openssl備份

mv /usr/bin/openssl /usr/bin/openssl.oldmv /usr/include/openssl /usr/include/openssl.old

2、下載1.1版本的openssl,并解壓編譯

 wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz tar zxvf openssl-1.1.0g.tar.gz cd openssl-1.1.0g/ ./config --prefix=/usr/local/openssl shared zlib make depend make && make install  ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl ln -s /usr/local/openssl/include/openssl /usr/include/openssl(首選) cd /usr/local/openssl/lib ln -s libssl.so.1.1 libcrypto.so.1.1 /lib/x86_64-linux-gnu/ echo /usr/local/openssl/lib >> /etc/ld.so.conf

3、驗證openssl版本信息

openssl versionif [[ `openssl version |awk '{print $2}'` == 1.1.0g ]];then   echo okfi

nginx升級(源碼編譯)

原配置文件不會丟失

1、下載源碼包

wget http://nginx.org/download/nginx-1.12.2.tar.gz 

2、解壓編譯安裝

編譯安裝 nginx 時,--with-openssl 參數默認只支持OpenSSL的源代碼,不支持已編譯好的 OpenSSL。可以在nginx的解壓目錄下修改auto/lib/openssl/conf

sed "s/.openssl////" c

將文件中的.openssl去掉,就可以支持編譯之后的openssl路徑了

CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include"CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h"CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a"CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a"

正式編譯

 ./configure --prefix=/etc/nginx / --sbin-path=/usr/sbin/nginx / --conf-path=/etc/nginx/nginx.conf / --error-log-path=/var/log/nginx/error.log / --http-log-path=/var/log/nginx/access.log / --pid-path=/var/run/nginx.pid / --lock-path=/var/run/nginx.lock / --http-client-body-temp-path=/var/cache/nginx/client_temp / --http-proxy-temp-path=/var/cache/nginx/proxy_temp / --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp / --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp / --http-scgi-temp-path=/var/cache/nginx/scgi_temp / --with-http_ssl_module / --with-http_realip_module / --with-http_addition_module / --with-http_sub_module / --with-http_dav_module / --with-http_flv_module / --with-http_mp4_module / --with-http_gunzip_module / --with-http_gzip_static_module / --with-http_random_index_module / --with-http_secure_link_module / --with-http_stub_status_module / --with-http_auth_request_module / --with-threads / --with-stream / --with-stream_ssl_module / --with-http_slice_module / --with-mail / --with-mail_ssl_module / --with-file-aio / --with-http_v2_module / --with-openssl=/usr/local/openssl

修改nginx配置

listen 443 ssl http2;

出現的問題及解決

centos7下openssl version報錯openssl: error while loading shared libraries: libssl.so.1.1

echo /usr/local/openssl/lib >> /etc/ld.so.conf # 將openssl編譯路徑的lib庫加入到/etc/ld.so.confldconfig -v|grep libssl  # 檢查是否添加成功

nginx重啟出現錯誤,nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed

ls -l /var/cache/nginx/client_temp#檢查該文件夾是否存在和文件夾的權限mkdir -p /var/cache/nginx/client_temp #文件夾不存在則生成文件夾chown -R www-data:www-data /var/cache/nginx/client_temp # 將文件夾所有者和組改為nginx的運行用戶,具體見nginx.conf

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網。


注:相關教程知識閱讀請移步到服務器教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亚东县| 泰安市| 抚州市| 巴林左旗| 醴陵市| 镇平县| 兴国县| 家居| 湟中县| 英超| 开封市| 大姚县| 嘉祥县| 什邡市| 龙胜| 唐海县| 环江| 扶沟县| 河北省| 萨迦县| 疏勒县| 文登市| 成都市| 调兵山市| 临夏县| 凤台县| 林周县| 遵化市| 静乐县| 红原县| 双城市| 普宁市| 密云县| 海淀区| 财经| 盐源县| 建水县| 乐陵市| 黄龙县| 丽水市| 临沧市|