編譯安裝tengine和熱公升級nginx

2021-10-10 09:44:58 字數 4339 閱讀 7203

增加乙個三方模組,能夠統計nginx中請求的狀態資訊

[root@slb1 ~]# wget
[root@slb1 ~]# wget  -o ngx_req_status.zip
3.解壓到同級目錄下
[root@slb1 ~]# tar -xf tengine-2.3.2.tar.gz 

[root@slb1 ~]# unzip ngx_req_status.zip

4.安裝環境和依賴包
[root@slb1 ~]# yum -y install pcre pcre-devel openssl openssl-devel gcc gcc-c++   zlib zlib-devel  patch.x86_64
5.建立使用者
[root@slb1 ~]# useradd  nginx

[root@slb1 ~]# passwd nginx

6.建立標頭檔案
[root@slb1 ~]# patch -p1 < ../ngx_req_status-master/write_filter-1.7.11.patch
7.配置
[root@slb1 tengine-2.3.2]# ./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream  --add-module=/usr/local/ngx_req_status-master
8.編譯
[root@slb1 tengine-2.3.2]# make -j 4
9.安裝
[root@slb1 tengine-2.3.2]# make install
10.檢測配置檔案
[root@slb1 ~]# /usr/local/nginx/sbin/nginx -t

[root@slb1 ~]# mkdir /tmp/nginx

11.啟動nginx服務
[root@slb1 ~]# /usr/local/nginx/sbin/nginx
12.修改配置檔案
[root@slb1 ~]# vi /etc/nginx/nginx.conf

#在http配置塊第一行插入

req_status_zone server_name $server_name 256k;

req_status_zone server_addr $server_addr 256k;

req_status_zone server_url $server_name$uri 256k;

#在server配置塊新增

req_status server_name server_addr server_url;

location /req-status

[root@slb1 ~]# /usr/local/nginx/sbin/nginx -s reload
14.nginx狀態檢視
[root@slb1 ~]# curl slb1/req-status

zone_name key max_active max_bw traffic requests active bandwidt

hserver_addr 172.18.0.6 2 336 24k 8 1 0

server_name localhost 2 336 24k 8 1 0

server_url localhost/ 1 0 0 3 0 0

server_url localhost/index.html 1 336 19k 3 0 0

server_url localhost/nginx-status 1 0 5800 1 0 0

server_url localhost/req-status 1 0 0 1 1 0

增加乙個三方模組,實現對後端的伺服器進行主動健康檢查

[root@slb1 ~]# wget
2.解壓到與nginx原始碼同級目錄
[root@slb1 ~]# unzip master.zip
3.清除之前編譯的可執行檔案及配置檔案
[root@slb1 tengine-2.3.2]# make clean
4.配置
./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream  --add-module=/usr/local/ngx_req_status-master --add-module=/usr/local/nginx_upstream_check_module-master/
5.編譯
[root@slb1 tengine-2.3.2]# make -j 4
6.備份原來的nginx
[root@slb1 tengine-2.3.2]# cp /usr/local/nginx/sbin/nginx
7.覆蓋原來的nginx
[root@slb1 tengine-2.3.2]# cp objs/nginx /usr/local/nginx/sbin/nginx

#失敗執行 pkill nginx 重新執行

8.修改配置檔案
[root@slb1 tengine-2.3.2]# vi /etc/nginx/nginx.conf

#在http配置塊中新增

upstream c1

#在server配置塊新增

location /status

[root@slb1 tengine-2.3.2]# /usr/local/nginx/sbin/nginx -s reload
10.檢視自主檢查結果
[root@slb1 tengine-2.3.2]# curl slb1/status?format=json

, ,

]}}

安裝Tengine和Tengine說明

什麼是tengine 官方幫助文件 tengine的安裝 新建tengine使用者組 groupadd r nginx useradd r g nginx m nginx 解壓安裝包 tar zxvf tengine 2.1.0.tar.gz安裝依賴 yum install gcc devel op...

CentOS 7 4 編譯安裝Tengine

tengine官網上有個非常簡單的教程,中間並未涉及到一些常用的設定,所以僅供參考。一下午為本人的安裝步驟及過程。配置firewalld,iptables,關閉selinux 1 安裝必要的編譯環境好 由於tengine安裝需要使用源 自行編譯,所以在安裝前需要安裝必要的編譯工具 yum y upd...

CentOS 7 2編譯安裝Tengine

tengine官網上有個非常簡單的教程,中間並未涉及到一些常用的設定,所以僅供參考。一下午為本人的安裝步驟及過程。配置firewalld,iptables,關閉selinux 1 安裝必要的編譯環境好 由於tengine安裝需要使用源 自行編譯,所以在安裝前需要安裝必要的編譯工具 yum y upd...