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!