Home  >  Article  >  Operation and Maintenance  >  How to add new module to nginx?

How to add new module to nginx?

青灯夜游
青灯夜游Original
2019-06-13 18:22:208461browse

How to add new module to nginx?

Steps to add a new module to nginx:

1. Download the module


git clone https://github.com/agentzh/echo-nginx-module

2. Put it into the specified location


mv echo-nginx-module-master /usr/local/src/nginx-1.8.1/echo-nginx-module

3. View the compiled parameters


/usr/local/nginx/sbin/nginx -V

The result is:

--user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6

4. Recompile


./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=/usr/local/src/nginx-1.8.1/echo-nginx-module --with-ipv6 
make

PS: Only make is required here, be sure not to execute make install, otherwise it will overwrite

5. Backup Original file


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

6. Replace nginx binary file


cp /usr/local/src/nginx-1.8.1/objs/nginx /usr/local/nginx/sbin/nginx

7. Check and smoothly start nginx


ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx(做软链,添加到环境变量)
nginx -t (检测配置文件)
nginx -s reload (平滑重启)

The above is the detailed content of How to add new module to nginx?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn