本文详细介绍了为Nginx动态添加模块的方法。原文中的解读非常细腻,编码有助于大家更好的理解和学习训练,有兴趣的朋友可以掌握。
写在前面
很多情况下,人们根据当时新的项目情况和业务流程需求安装Nginx后,随着之后业务流程的发展趋势,通常会在已安装的Nginx上增加其他功能模块。为Nginx添加功能模块时,规定Nginx不能关闭。这就涉及到如何动态的给安装好的Nginx添加模块的问题。在这篇文章中,我将和我的朋友们讨论如何在已安装的Nginx中动态添加模块。
为Nginx动态添加模块
以第三方ngx_http_google_filter_module模块的安装为例。
Nginx的模块是Nginx必须重新编译,而不是引入。像Apache这样的环境变量。
下载免费第三方扩展模块ngx_http_google_filter_module
#cd/data/software/ #gitclonehttps://github.com/cuber/ngx_http_google_filter_module查询nginx编译安装时安装了哪些模块
将cmd转换为Nginx程序执行所属的文件目录并键入。/nginx-V,实际如下:
[root@binghesbin]#./nginx-V nginxversion:nginx/1.19.1 builtbygcc4.4.720120313(RedHat4.4.7-17)(GCC) builtwithOpenSSL1.0.222Jan2015 TLSSNIsupportenabled configurearguments:--prefix=/usr/local/nginx-1.19.1--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@binghesbin]#可以看出,编译安装Nginx应用的主要参数如下:
--prefix=/usr/local/nginx-1.19.1--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-add-module=/data/software/ngx_http_Google_filter_module此处。
实际:
./configure--prefix=/usr/local/nginx-1.19.1--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如上,添加Nginx之前安装的所有主要参数,最后添加-add-module=/data/software/NGX_http_Google_filter_module。
今后,我们将进行实际的编译 *** 作,具体如下:
#make//千万别makeinstall,要不然就确实遮盖这里,必须注意的是,没有必要执行makeinstall命令。
替换nginx二进制文件
#备份数据原先的nginx程序执行 #mv/usr/local/nginx-1.19.1/sbin/nginx/usr/local/nginx-1.19.1/sbin/nginx.bak #将新编译的nginx程序执行拷贝到/usr/local/nginx-1.19.1/sbin/文件目录下 #cp/opt/nginx/sbin/nginx/usr/local/nginx-1.19.1/sbin/好了,今天到此为止吧!别忘了喜欢,给别人看,分享,让一大批人看到,一起学习,一起发展!!
以上是如何为Nginx动态添加模块的详细内容。关于为Nginx动态添加模块的大量资料请关注其他相关文章!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)