溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

怎么為已安裝的Nginx動(dòng)態(tài)添加模塊

發(fā)布時(shí)間:2021-12-04 10:20:08 來(lái)源:億速云 閱讀:135 作者:小新 欄目:服務(wù)器

小編給大家分享一下怎么為已安裝的Nginx動(dòng)態(tài)添加模塊,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

為Nginx動(dòng)態(tài)添加模塊

這里以安裝第三方ngx_http_google_filter_module模塊為例。

Nginx的模塊是需要重新編譯Nginx,而不是像Apache一樣配置文件引用.so

下載第三方擴(kuò)展模塊ngx_http_google_filter_module

# cd /data/software/

# git clone https://github.com/cuber/ngx_http_google_filter_module

查看nginx編譯安裝時(shí)安裝了哪些模塊

將命令行切換到Nginx執(zhí)行程序所在的目錄并輸入./nginx -V,具體如下:

[root@binghe sbin]# ./nginx -V

nginx version: nginx/1.19.1

built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)

built with OpenSSL 1.0.2 22 Jan 2015

TLS SNI support enabled

configure arguments: --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@binghe sbin]#

可以看出編譯安裝Nginx使用的參數(shù)如下:

--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

具體如下:

./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的參數(shù)全部加上,最后添加  --add-module=/data/software/ngx_http_google_filter_module

之后,我們要進(jìn)行編譯操作,如下:

# make //千萬(wàn)不要make install,不然就真的覆蓋

這里,需要注意的是:不要執(zhí)行make install命令。

替換nginx二進(jìn)制文件

# 備份原來(lái)的nginx執(zhí)行程序

# mv /usr/local/nginx-1.19.1/sbin/nginx  /usr/local/nginx-1.19.1/sbin/nginx.bak

# 將新編譯的nginx執(zhí)行程序復(fù)制到/usr/local/nginx-1.19.1/sbin/目錄下

# cp /opt/nginx/sbin/nginx /usr/local/nginx-1.19.1/sbin/

以上是“怎么為已安裝的Nginx動(dòng)態(tài)添加模塊”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI