已安裝nginx動態新增模組
阿新 • • 發佈:2019-01-05
http://www.cnblogs.com/lixigang/articles/5130052.html
說明:
已經安裝好的nginx,需要新增一個未被編譯安裝的模組,需要怎麼弄呢?
具體:
這裡以安裝第三方ngx_http_google_filter_module模組為例
nginx的模組是需要重新編譯nginx,而不是像apache一樣配置檔案引用.so
1. 下載第三方擴充套件模組ngx_http_google_filter_module
# cd /data/software/
# git clone https://github.com/cuber/ngx_http_google_filter_module
2. 檢視nginx編譯安裝時安裝了哪些模組
# nginx -V
nginx version: nginx/1.8.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/data/software/ngx_http_substitutions_filter_module
可以看出編譯安裝使用了--prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/data/software/ngx_http_substitutions_filter_module這些引數。--add-module=/data/software/ngx_http_substitutions_filter_module是之前編譯新增ngx_http_substitutions_filter_module模組時新增
3. 加入需要安裝的模組,重新編譯,如這裡新增–add-module=/data/software/ngx_http_google_filter_module
# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --add-module=/data/software/ngx_http_substitutions_filter_module --add-module=/data/software/ngx_http_google_filter_module
# make //千萬不要make install,不然就真的覆蓋了
4. 替換nginx二進位制檔案:
# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
# cp ./objs/nginx /usr/local/nginx/sbin/