How to dynamically add modules to an installed Nginx
Editor to share with you how to dynamically add modules for the installed Nginx, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Dynamically add modules for Nginx
Take the installation of the third-party NGX _ http_google_filter_module module as an example.
The module of Nginx needs to recompile Nginx instead of referencing .so in the configuration file like Apache.
Download the third-party expansion module ngx_http_google_filter_module
# cd / data/software/
# git clone https://github.com/cuber/ngx_http_google_filter_module
See which modules are installed when nginx is compiled and installed
Change the command line to the directory where the Nginx executor is located and type. / nginx-V, as follows:
[root@binghe sbin] #. / nginx-V
Nginx version: nginx/1.19.1
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.19.1-- 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@binghe sbin] #
You can see that the parameters used to compile and install Nginx are as follows:
-prefix=/usr/local/nginx-1.19.1-- 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 modules that need to be installed and recompile
Add-- add-module=/data/software/ngx_http_google_filter_module here
The details are as follows:
/ configure-- prefix=/usr/local/nginx-1.19.1-- 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 parameters that previously installed Nginx, and finally add-- add-module=/data/software/ngx_http_google_filter_module
After that, we will compile as follows:
# make / / do not make install, or you will really overwrite it
Here, it is important to note that do not execute the make install command.
Replace nginx binaries
# back up the original nginx execution program
# mv / usr/local/nginx-1.19.1/sbin/nginx / usr/local/nginx-1.19.1/sbin/nginx.bak
# copy the newly compiled nginx executor to the / usr/local/nginx-1.19.1/sbin/ directory
# cp / opt/nginx/sbin/nginx / usr/local/nginx-1.19.1/sbin/
The above is all the contents of the article "how to dynamically add modules to the installed Nginx". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!