Nginx dynamically adds modules to the installed nginx
- 2020-05-14 06:02:06
- OfStack
Here is an example of installing the 3rd party ngx_http_google_filter_module module
The module of nginx is required to recompile nginx instead of reference to 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
Switch the command line to the directory where nginx executes and type./ nginx-V, as follows:
[root@liuyazhuang121 sbin]# ./nginx -V
nginx version: nginx/1.9.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.2 22 Jan 2015
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx-1.9.3 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module
[root@liuyazhuang121 sbin]#
Can see compiler installed - prefix = / usr/local/nginx - 1.9.3 - with - openssl = / usr local/src/openssl - 1.0.2 - with - pcre = / usr local/src/pcre - 8.37 - with - zlib = / usr local/src/zlib - 1.2.8 -- with-http_ssl_module.
3. Add the modules to be installed and recompile
Here, add -wound63en-module =/data/software/ngx_http_google_filter_module
The details are as follows:
./configure --prefix=/usr/local/nginx-1.9.3 --with-openssl=/usr/local/src/openssl-1.0.2 --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-http_ssl_module - � add-module=/data/software/ngx_http_google_filter_module
As above, add all the previous Nginx installation parameters, and finally add - - wok add-module =/data/software/ ngx_http_filter_filter_module
After that, we will compile as follows:
# make // Don't be make install Otherwise it will be covered
4. Replace the nginx2 base file
# Back up the original nginx Execute a program
# cp /usr/local/nginx-1.9.3/sbin/nginx /usr/local/nginx-1.9.3/sbin/nginx.bak
# Will be newly compiled nginx Execute program copy to /usr/local/nginx/sbin/ directory
# cp /opt/nginx/nginx /usr/local/nginx/sbin/