nginx installs third-party modules

How to install nginx third-party modules (2 cases where nginx is already installed and nginx is not installed)

For example: install the third-party ngx_cache_purge module (used to clear the cache of the specified URL), the nginx installation directory is assumed to be in /usr/local/nginx

Download and unzip:

wget http://labs.frickle.com/files/ngx_cache_purge-2.0.tar.gz

tar -zxvf ngx_cache_purge-2.0.tar.gz (目录 : / usr / local / src /

 

Enter the nginx source directory (/usr/local/src/nginx/)

cd /usr/local/nginx/

 

 

When nginx is not installed

Approximate command: ./configure --prefix=/your installation directory   --add-module=/third-party module directory  (you can also add other required compilation parameters, such as: --with-http_ssl_module, etc.)

1. Specific order:

./configure --user=root --group=root --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.30 --with-zlib=/usr/local/src/zlib-1.2.3 --add-module=/usr/local/src/ngx_cache_purge-2.0

2. Compile: make

3. Installation: make install

 

 

With nginx installed

Principle: Recompile nginx, but do not install it, but overwrite the old nginx file with the compiled nginx (objs/nginx in the source directory). When recompiling, it is best to keep the same compilation parameters as the old compilation command.

 

1. View the parameters (installed modules) of the installed nginx when compiling: /usr/local/nginx/sbin/nginx -V 

以上命令显示如:configure arguments: --user=root --group=root --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.30 --with-zlib=/usr/local/src/zlib-1.2.3

 

2. Recompile nginx and install third-party modules through --add-module

Specific command:

./configure --user=root --group=root --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.30 --with-zlib=/usr/local/src/zlib-1.2.3 --add-module=/usr/local/src/ngx_cache_purge-2.0

 

3. Compile:

make

 

4. Overwrite the old nginx file: (need to stop nginx first)

cp objs/nginx /usr/local/nginx/sbin/

 

restart nginx

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326606271&siteId=291194637