3,為nginx啟用ngx_http_v2_module模塊


生產環境的nginx當初沒有編譯啟用ngx_http_v2_module模塊

[root@nginx51 ~]# /opt/nginx/sbin/nginx -V
nginx version: nginx/1.12.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --user=nginx --group=nginx --with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module --with-pcre=/tmp/pcre-8.40 --with-stream

 

現在業務上要用到這個模塊,需要把它重新編譯進去但不影響業務

步驟:

進入到nginx源碼目錄重新編譯,通過--with-http_v2_module啟用ngx_http_v2_module模塊,然后make (注意不要make install,否則直接覆蓋了)

cd /tmp/nginx-1.12.0                # nginx源碼版本必須和當前生產環境的nginx一致
./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module --with-pcre=/tmp/pcre-8.40 --with-stream --with-http_v2_module
make

 

meke好了之后會在源碼目錄下的objs目錄產生nginx的二進制,先不要make install

[root@nginx51 objs]# cd /tmp/nginx-1.12.0/objs/
[root@nginx51 objs]# ls
autoconf.err  Makefile  nginx  nginx.8  ngx_auto_config.h  ngx_auto_headers.h  ngx_modules.c  ngx_modules.o  src

 

然后把原先的nginx二進制命令備份,用上面編譯好的nginx替換,最后reload的nignx就可以

[root@nginx51 ~]# cd /opt/nginx/sbin/
[root@nginx51 sbin]# mv nginx nginx.bak                 # 備份
[root@nginx51 sbin]# cp /tmp/nginx-1.12.0/objs/nginx .  # 把編譯好的nginx拷貝過來
[root@nginx51 sbin]# service nginx reload               # 重載nginx

 

在通過nginx -V測試,可以看到--with-http_v2_module,說明ok了

[root@nginx51 sbin]# /opt/nginx/sbin/nginx -V
nginx version: nginx/1.12.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --user=nginx --group=nginx 
--with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module 
--with-pcre=/tmp/pcre-8.40 --with-stream --with-http_v2_module

 

其它模塊的啟用也是類似的。順便說下make和make install, make是把源碼編譯成可執行的二進制,make install是把編譯好的二進制或一些文件安裝到指定的路徑.

另外nginx1.10版本可以動態添加模塊

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM