讓我們的站點支持http2|nginx支持http2

之前寫過Ubuntu如何安裝nginx:http://blog.51cto.com/11140372/2335820
這裏看如何將站點改成http2(http2的好處不言而喻,自行百度):


wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_1a.tar.gz
tar zxvf OpenSSL_1_1_1a.tar.gz

cd nginx-1.15.8/
#通過--with-http_v2_module 打包http2 --with-openssl指定openssl目錄
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_v2_module --with-openssl=../openssl-OpenSSL_1_1_1a
make -j2

sudo make install 
#最後在nginx conf server下配置

listen 443 ssl http2;
server_name  localhost;

ssl_certificate_key /home/anfang/Downloads/cert/key.pem;
ssl_certificate   /home/anfang/Downloads/cert/cert.pem;

這是我配置laravel的nginx配置文件,現在改成了http2的:
看我之前laravel的配置過程:http://blog.51cto.com/11140372/2335680
讓我們的站點支持http2|nginx支持http2
到這裏重啓nginx,然後訪問頁面:https://yourip 即可。我的Chrome瀏覽器的版本支持http2。
如何判斷網站是否使用了HTTP/2:https://blog.csdn.net/Edu_enth/article/details/85318840

其中的key.pem和cert.pem自己可以通過openssl生成。或者下載我的:http://down.51cto.com/data/2457495

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