This article mainly introduces the method of adding modules to Nginx. It has certain reference value. Now I share it with you. Friends in need can refer to
If you have installed Nginx, you need to add a new one. Module, what do I need to do?
Take the module nginx-sticky-module-ng as an example
View the last compilation and installation parameters of Nginx
[~]$ nginx -V nginx version: nginx/1.10.0 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module
In the data output by the command, the configure arguments
item is the last compilation parameter and needs to be reused.
Back up the original Nginx executable file
Download the original version of the Nginx source code package and unzip it
Download third-party extension module
git clone https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng.git
Add new modules that need to be installed and recompile
If it is a third party If it is a module, specify the directory; if it is a built-in module, specify the module name.
./configure --prefix=/你的安装目录 --add-module=/第三方模块目录
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --add-module=./nginx-sticky-module-ng // make后不要执行install,改用手动拷贝 make // 强制覆盖执行文件 sudo cp -rfp objs/nginx /usr/local/nginx/sbin/nginx
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
The above is the detailed content of How to add modules to Nginx. For more information, please follow other related articles on the PHP Chinese website!