Nginx is the method for dynamically adding modules to the installed nginx

  • 2020-05-14 06:02:11
  • OfStack

Description:

nginx is already installed, so you need to add a module that has not been compiled and installed. What do you need to do?

Specific:

Here is an example of installing the 3rd party ngx_http_google_filter_module module

The module of nginx is required to recompile nginx, not reference the configuration file like apache1.so

1. Download the 3rd party extension module ngx_http_google_filter_module


# cd /data/software/
# git clone https://github.com/cuber/ngx_http_google_filter_module

2. See what modules were installed when nginx was compiled and installed


# nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/data/software/ngx_http_substitutions_filter_module

You can see that the build installation USES --prefix=/usr/local/nginx -- with-http_module -- with-ssl_module -- with-sub_module -- with-sub_http_gzip_static_http_status_module -- add-module =/data/software/ ngx_http_filter_module -- add-module =/data/software/ngx_http_substitutions_filter_module was added when the ngx_http_substitutions_filter_module module was added

3. Add the modules that need to be installed and recompile, such as here to add the wok: add-module =/data/software/ngx_http_google_filter_module


# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/data/software/ngx_http_substitutions_filter_module --add-module=/data/software/ngx_http_google_filter_module
# make  // Don't be make install Otherwise it will be overwritten 

4. Replace nginx2 files:


# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
# cp ./objs/nginx /usr/local/nginx/sbin/

Related articles: