温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

让我们的站点支持http2|nginx支持http2

发布时间:2020-05-30 08:03:51 来源:网络 阅读:1001 作者:wz669 栏目:建站服务器

之前写过Ubuntu如何安装nginx:https://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的配置过程:https://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

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI