Get the App
SLTechnology News&Howtos  ›  Servers  › 

Nginx dynamically adds modules to the installed nginx

Shulou Source: shulou.com Published: 2022-06-02 01:26:18 09月20日 Update

Here, 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.

1. 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

two。 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@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] #

You can see that the compilation installation uses these parameters-- 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 modules that need to be installed and recompile

Add-- add-module=/data/software/ngx_http_google_filter_module here

The details are as follows:

The copy code is 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 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

4. Replace nginx binaries

# backup the original nginx executor # cp / usr/local/nginx-1.9.3/sbin/nginx / usr/local/nginx-1.9.3/sbin/nginx.bak # copy the newly compiled nginx executor to the / usr/local/nginx/sbin/ directory # cp / opt/nginx/nginx / usr/local/nginx/sbin/

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Tags: Compile module program code parameter file directory third party binary content command backup as above is where switch learn help support input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MariaDB Xiaomi NVidia Docker