nginx第三方模塊安裝方法


nginx第三方模塊安裝方法

./configure --prefix=/你的安裝目錄  --add-module=/第三方模塊目錄

比如echo模塊。
沒安裝前,使用測試。

location /test {
	echo "test here";
}

提示:

# sudo nginx -s reload
nginx: [emerg] unknown directive "echo" in /usr/local/nginx/conf/vhost/wounion.conf:26

說明並不能使用。

下面進行安裝,
先查看已經有的模塊。

# nginx -V
nginx version: nginx/1.12.2
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 
built with OpenSSL 1.0.2l  25 May 2017
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 --with-openssl=/usr/local/lnmp1.4-full/src/openssl-1.0.2l --with-http_image_filter_module

在nginx安裝目錄中創建文件夾third_moule。
下載echo模塊到nginx安裝目錄中的third_moule。

wget https://github.com/openresty/echo-nginx-module/archive/v0.61.tar.gz

解壓

sudo tar -zxvf v0.61.tar.gz 

編譯

sudo ./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 --with-openssl=/usr/local/lnmp1.4-full/src/openssl-1.0.2l --with-http_image_filter_module --add-module=/usr/local/lnmp1.4-full/src/nginx-1.12.2/third_module/echo-nginx-module-0.61

安裝

sudo make

替換二級制文件

sudo cp -f ./objs/nginx /usr/local/nginx/sbin/nginx

再次查看包含模塊

# nginx -V
nginx version: nginx/1.12.2
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 
built with OpenSSL 1.0.2l  25 May 2017
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 --with-openssl=/usr/local/lnmp1.4-full/src/openssl-1.0.2l --with-http_image_filter_module --add-module=/usr/local/lnmp1.4-full/src/nginx-1.12.2/third_module/echo-nginx-module-0.61

再次重啟nginx試試echo模塊。

sudo nginx -s reload

正常的,並沒有報錯。

# curl  http://jiqing.wounion.com/test
test here


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM