网站首页 文章专栏 centos6、7 编译安装nginx加添加http2 协议支持
centos6、7 编译安装nginx加添加http2 协议支持
编辑时间:2019年11月26日 10:37 作者:赵彦昌 浏览量:2015


centos 官方源里面nginx 不管哪个版本(包括最新1.17)  都不支持http2 协议, 需要我们自己编译nginx 源代码来支持http2

你可以在你自己的 nginx 环境 使用 nginx -V  查看 nginx built with OpenSSL 1.1.1d  10 Sep 2019 是哪个版本的,必须是openssl 1.0.2e 或以上

接下来,我们需要做得是

1. 升级centos 的 openssl 二进制文件 

2. 下载nginx 和 openssl  源代码,openssl 版本和你使用的二进制版本保持一致

3. 使用nginx -V 查看现在nginx 编译时的参数, 在原有基础上面加上--with-http_v2_module --with-openssl=/path/openssl-1.1.1d-src

4. ./configur .....  && make 不要make install  因为我们是升级不是新安装。编译好后, 在 nginx objs 目录下的nginx 覆盖原来nginx 二进制文件

5. service nginx restart  


可能遇到的问题

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决:


yum -y install pcre-devel





来说两句吧
最新评论