给已经编译安装了的nginx 添加http_ssl_module和http_v2_module模块方法(让Web服务器支持SSL和http2)

给已经编译安装了的nginx 添加http_ssl_module和http_v2_module模块方法(让Web服务器支持SSL和http2)

Vanish
2016-08-15 / 1 评论 / 1,973 阅读 / 正在检测是否收录...
    昨天给AMH4.2升级nginx后,想要使网站使用https,支持SSL和HTTP2,今天给网站<a href="https://vzone.me/873/" target="_blank">配置nginx规则</a>的时候,重启nginx却失效。

仔细检查规则后突然想起之前老版本的nginx只编译安装了SSL(http_ssl_module模块),却没有编译安装https(http_v2_module模块)。

所以又开始百度找高手写的文章学习怎么不重装nginx的情况下添加新的http_v2_module模块,让其支持http2

好了下面开始添加方法:
nginx -V

然后我们可以看得到这样的信息。

<strong>1、首选<span style="color:#303030;font-family:微软雅黑, &quot;font-size:16px;line-height:32px;">看下编译安装nginx的时候,都编译安装的哪些模块。</span></strong>

nginx version: nginx/1.9.9
built by gcc 4.7.2 (Debian 4.7.2-5) 
built with OpenSSL 1.0.1e 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module

仔细看就发现已经安装了http_ssl_module模块,缺少http_v2_module模块;

2、进入之前下载并解压了的源码包目录;重新编译nginx

<span> </span>
cd /usr/local/src/nginx-1.8.0

3、在刚才得到的编译信息后面添加http_v2_module模块
在 ./configure 中加入:--with-http_v2_module ,如果没有 SSL 支持,还需要加入--with-http_ssl_module

 ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module --with-http_v2_module

4、输入命令make进行编译 这一步千万不能 make install ;不然会把之前已经安装的nginx 覆盖掉 

<strong>5、需要替换nginx二进制文件,先停止掉nginx进程;备份一下原来的启动脚本。</strong>

cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old;

cp objs/nginx /usr/local/nginx/sbin/nginx;

6、查看nginx的模块,看下是否把需要的模块编译进去了

nginx -V

7、最后重新启动nginx

0

评论

博主关闭了所有页面的评论