1. 查看是否安裝檢查狀態(tài)模塊;
[root@localhost ~]# nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
configure arguments: --prefix=/usr/local/nginx --with-http_sub_module
2. 如未安裝,重新編譯安裝;
Ø 檢查狀態(tài)模塊;--with-http_stub_status_module
[root@localhost ~]# cd /usr/local/src/nginx-1.12.2/
[root@localhost ~]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
[root@localhost ~]# make && make install
3. 編輯nginx 的配置文件;
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name localhost;
#access_log logs/host.access.log main;
location /nginx_status {
stub_status on;
access_log off;
#allow 127.0.0.1; ##可對(duì)該頁(yè)面的訪問者進(jìn)行過(guò)濾
#deny all;
}
}
[root@localhost ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]# nginx -s reload
4.測(cè)試語(yǔ)法;
[root@localhost ~]# curl http://192.168.10.110:80/nginx_status
Active connections: 1
server accepts handled requests
1 1 1
Reading: 0 Writing: 1 Waiting: 0
5. 輸出內(nèi)容詳解;
第一行 Active connections: 1 ——活躍的連接數(shù)量,包括等待客戶端數(shù)0 |
第二行 server accepts handled requests —— 總共處理了1個(gè)連接 , 成功創(chuàng)建1次握手, 總共處理了1個(gè)請(qǐng)求 |
第三行 Reading — 讀取客戶端的連接數(shù),Writing — 響應(yīng)數(shù)據(jù)到客戶端的數(shù)量,Waiting — 開啟 keep-alive 的情況下,這個(gè)值等于 active – (reading+writing), 意思就是 Nginx 已經(jīng)處理完正在等候下一次請(qǐng)求指令的駐留連接. |
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。