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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章