1. 程式人生 > >Nginx第三方模組Ngx-dyups安裝過程

Nginx第三方模組Ngx-dyups安裝過程

Ngx-dyups是什麼,能幹什麼

它是一個Nginx第三方動態Upstream配置模組,可以實現在不重啟Nginx情況下動態更新反向代理Upstream表。該模組由淘寶開發團隊維護,淘寶自家的Tengine中雖然沒有直接整合該模組,但可以通過重新編譯方式加進去。

 

原始碼地址

https://github.com/yzprofile/ngx_http_dyups_module

 

Ngx-dyups安裝 

1、下載第三方模組

git clone git://github.com/yzprofile/ngx_http_dyups_module.git

2、將第三方模組目錄複製到最初Openresty下載解壓縮目錄下,當然,也可以放到任意目錄下,只是這樣編譯時需要指定該目錄。

[[email protected] ~]$ cp -r  ngx_http_dyups_module openresty-1.11.2.5

第一次就因為沒做這一步複製,最後報錯如下

adding module in /home/test/openresty-1.11.2.5/ngx_http_dyups_module

./configure: error: no /home/test/openresty-1.11.2.5/ngx_http_dyups_module/config was found

ERROR: failed to run command: sh ./configure --prefix=/usr/local/openresty/nginx \...

3、切換到Openresty最初下載解壓縮目錄下

[[email protected]]$ cd openresty-1.11.2.5

4、以管理員身份執行./configure --add-module,注意,必須以管理員身份,這個重新編譯過程非常長

[[email protected] openresty-1.11.2.5]$ sudo ./configure --add-module=./ngx_http_dyups_module

編譯過程中會不停刷屏顯示各種命令,都可以無視,但一定要注意最後的部分

adding module in ../rds-csv-nginx-module-0.07

 + ngx_http_rds_csv_filter_module was configured

adding module in /home/test/openresty-1.11.2.5/ngx_http_dyups_module

 + dyups module support lua

 + ngx_http_dyups_module was configured         這一句很關鍵,表示安裝成功了

checking for PCRE library ... found

checking for PCRE JIT support ... found

5、以管理員身份執行make

[[email protected] openresty-1.11.2.5]$ sudo make

6、如果Nginx程序仍啟動中,則先關閉Nginx程序

7、切換到Make好的新檔案所在目錄

[[email protected] openresty-1.11.2.5]$ cd build

[[email protected] build]$ cd nginx-1.11.2

[[email protected] nginx-1.11.2]$ cd objs

8、檢視Nginx是否關閉了

[[email protected] objs]$ ps -ef |grep nginx

test      98103  77025  0 05:35 pts/0    00:00:00 grep --color=auto nginx

9、將新的Nginx檔案複製到目標目錄

 [[email protected] objs]$ cp nginx /usr/local/openresty/nginx/sbin/

10、啟動Nginx並檢視是否新Module加進去了

[[email protected] openresty]$ sudo ./nginx/sbin/nginx -c conf/nginx.conf

[[email protected] openresty]$ sudo ./nginx/sbin/nginx -V

nginx version: openresty/1.11.2.5

built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)

built with OpenSSL 1.0.2k-fips  26 Jan 2017

TLS SNI support enabled

configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.61 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.31 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.06 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.10 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.32 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.18 --add-module=../redis2-nginx-module-0.14 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.07 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --add-module=/home/test/openresty-1.11.2.5/ngx_http_dyups_module --with-http_ssl_module