寶塔Nginx 安裝check模塊nginx_upstream_check_module

第一步:在寶塔安裝nginx,選擇編譯安裝

第二步:在這個基礎上加新增模塊nginx_upstream_check_module,步驟如下

1.執行命令獲取nginx_upstream_check_module模塊:
  wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master

2.進入nginx安裝的目錄

[root@hlt ~]# ps -ef|grep nginx
root     16986     1  0 16:59 ?        00:00:00 nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf
www      16987 16986  0 16:59 ?        00:00:00 nginx: worker process                                            
www      16988 16986  0 16:59 ?        00:00:00 nginx: worker process                                            
www      16989 16986  0 16:59 ?        00:00:00 nginx: worker process                                            
www      16990 16986  0 16:59 ?        00:00:00 nginx: worker process                                            
www      16991 16986  0 16:59 ?        00:00:00 nginx: worker process                                            
www      16992 16986  0 16:59 ?        00:00:00 nginx: worker process                                            
www      16993 16986  0 16:59 ?        00:00:00 nginx: worker process                                            
www      16994 16986  0 16:59 ?        00:00:00 nginx: worker process                                            
www      16995 16986  0 16:59 ?        00:00:00 nginx: cache manager process                                     
root     17091 17077  0 17:18 pts/1    00:00:00 grep nginx
[root@hlt ~]# cd /www/server/nginx/src/

3.打補丁找到nginx-1.14.2對應支持的nginx_upstream_check_module(不同版本請各自對應)

patch -p1 < /home/hwfwqlzh/nginxTool/nginx_upstream_check_module-master/check_1.14.0+.patch

4.運行 -V命令獲取當前的編譯配置,命令 /www/server/nginx/sbin/nginx -V

拷貝顯示出來的內容 configure arguments:之後的內容我的是 --user=www --group=www --prefix=/www/server/nginx --add-module=/www/server/nginx/src/ngx****** 後面很長的,自己複製自己服務器上的內容

5.在/www/server/nginx/src/目錄下運行下面的代碼./configure 後面的內容是剛剛上面獲取的,在裏面加入了紫色的代碼紫色的代碼路徑是解壓的第一步下載的文件:

./configure --user=www --group=www --prefix=/www/server/nginx --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/home/hwfwqlzh/nginxTool/nginx_upstream_check_module-master --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --with-openssl=/www/server/nginx/src/openssl --with-pcre=pcre-8.43 --with-http_v2_module --with-stream --with-stream_ssl_module --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc 

6.運行 make 命令 運行後的編譯文件在 /www/server/nginx/src/objs/nginx

7.備份 cp /www/server/nginx/sbin/nginx /www/server/nginx/sbin/nginx.bak

8.cp  /www/server/nginx/src/objs/nginx /www/server/nginx/sbin/

9.配置文件加入check模塊

 #===============check 測試==========================
upstream mycheck {
  server 127.0.0.1:8080;
  server 127.0.0.1:8083;
  check interval=3000 rise=2 fall=5 timeout=1000 type=http;
  check_http_send "GET /zzbNew/url.jsp HTTP/1.0\r\n\r\n";

}
server {
        listen       80;
        server_name  booking.homilychart.com;
        location / {
          proxy_pass http://mycheck;
        }
         location /status {
        check_status;
        access_log   off;
    #    allow 172.29.73.23;
     #   deny all;
      }
    }

#===============check 測試==========================
url.jsp 內容如下:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String por = request.getLocalAddr()+":"+request.getLocalPort();
request.setAttribute("por", por);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'url.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
     <style> 
        body{text-align:center} 
    </style> 
  </head>
  
  <body>
     <br>
     <h1>Server IP: ******</h1>
     <h1>Test Server ${por}</h1>
  </body>
</html>

10.運行重啓nginx測試

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章