Nginx 動態增加擴展


Nginx 動態增加擴展

1. 先查看目前nginx已加載模塊

/home/nginx-1.18.0 # nginx -V 
nginx version: nginx/1.18.0
built by gcc 9.3.0 (Alpine 9.3.0) 
configure arguments: --prefix=/usr/local/nginx --with-pcre=/home/pcre-8.44 --without-http_gzip_module
## 上述就是目前已安裝nginx參數配置

 

2. 編譯nginx,增加新擴展

/home/nginx-1.18.0 # ./configure --prefix=/usr/local/nginx --with-pcre=/home/pcre-8.44 --without-http_gzip_module  --with-http_gzip_static_modu
le --with-http_stub_status_module
............

............
## make

 /home/nginx-1.18.0 # make

 

3. 記得不要make install,否則會覆蓋原來nginx,這時候在當前目錄有個objs文件夾,該文件夾下面的nginx則是新編譯生成的nginx

/home/nginx-1.18.0 # ls
CHANGES     LICENSE     README      conf        contrib     man         src
CHANGES.ru  Makefile    auto        configure   html        objs

/home/nginx-1.18.0 # ls objs/

Makefile            nginx               ngx_auto_config.h   ngx_modules.c       src

autoconf.err        nginx.8             ngx_auto_headers.h  ngx_modules.o 

  

4. 拷貝現有nginx保留副本

/home/nginx-1.18.0 # cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

 

5. 將新編譯的nginx移至安裝目錄

/home/nginx-1.18.0 # mv objs/nginx /usr/local/nginx/sbin/

 

6. 查看是否動態增加成功

/home/nginx-1.18.0 # nginx -V
nginx version: nginx/1.18.0
built by gcc 9.3.0 (Alpine 9.3.0) 
configure arguments: --prefix=/usr/local/nginx --with-pcre=/home/pcre-8.44 --without-http_gzip_module --with-http_gzip_static_module --with-http_stub_status_module

## 上述已加載完成動態模塊

 

7. 重啟服務

/home/nginx-1.18.0 # nginx -s reload

 


免責聲明!

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



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