给已经编译安装了的nginx 添加http_ssl_module和http_v2_module模块方法(让Web服务器支持SSL和http2) 2016年08月15日 Vanish 2802 昨天给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的情况下添加新的<span>http_v2_module模块,让其支持http2 <strong>好了下面开始添加方法:</strong> `nginx -V` 然后我们可以看得到这样的信息。 <strong>1、首选<span style="color:#303030;font-family:微软雅黑, "font-size:16px;line-height:32px;">看下编译安装nginx的时候,都编译安装的哪些模块。</span></strong> <pre class="prettyprint"></pre> <span style="color:#333333;font-family:"font-size:16px;line-height:28.8px;background-color:#FFFFFF;"> </span> <pre class="prettyprint">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</pre> 仔细看就发现已经安装了http_ssl_module模块,缺少http_v2_module模块; <h3> <strong>2、</strong><strong>进入之前下载并解压了的源码包目录;重新编译nginx</strong><span id="__kindeditor_bookmark_start_73__"><strong></strong></span> </h3> <span> </span> <pre class="prettyprint">cd /usr/local/src/nginx-1.8.0</pre> <strong>3、在刚才得到的编译信息后面添加</strong><strong>http_v2_module模块</strong> <span><span style="color:#333333;font-family:"font-size:16px;line-height:32px;background-color:#FFFFFF;"><strong>在 </strong></span><strong>./configure</strong><span style="color:#333333;font-family:"font-size:16px;line-height:32px;background-color:#FFFFFF;"><strong> 中加入:</strong></span><span style="color:#E53333;background-color:#CCCCCC;"><strong>--with-http_v2_module</strong></span><span style="color:#333333;font-family:"font-size:16px;line-height:32px;background-color:#FFFFFF;"><strong> ,如果没有 SSL 支持,还需要加入</strong></span><span style="color:#E53333;background-color:#CCCCCC;"><strong>--with-http_ssl_module</strong></span><span style="color:#E53333;background-color:#CCCCCC;"><strong></strong></span></span> <span><span style="color:#E53333;background-color:#CCCCCC;"> </span></span> <pre class="prettyprint"> ./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 </pre> <h4 style="color:#303030;font-family:微软雅黑, Arial, Helvetica, sans-serif;font-size:16px;"> <span style="font-family:"font-size:12px;font-weight:normal;line-height:1.5;"><strong>4、输入命令make进行编译 <span style="color:#E53333;">这一步千万不能 make install ;不然会把之前已经安装的nginx 覆盖掉 </span></strong></span> </h4> <strong>5、需要替换nginx二进制文件,先停止掉nginx进程;备份一下原来的启动脚本。</strong> <strong> </strong> <pre class="prettyprint">cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old; cp objs/nginx /usr/local/nginx/sbin/nginx;</pre> <strong> 6、查看nginx的模块,看下是否把需要的模块编译进去了</strong> <strong> </strong> <pre class="prettyprint">nginx -V</pre> <strong> 7、最后重新启动nginx</strong> 版权声明:本文为原创文章,版权归 V-ZONE 所有,允许非商业转载,转载请用链接注明出处。 本文地址:https://vzone.me/875/ 如果对本文有什么问题或疑问都可以在评论区留言,我看到后会尽量解答。 学习 nginx SSL https http2
收藏备用。