首頁 > 運維 > Nginx > 主體

Nginx怎麼設定檢測服務狀態

WBOY
發布: 2023-05-31 11:13:06
轉載
2285 人瀏覽過

1. 檢視是否安裝檢查狀態模組;

[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.  如未安裝,重新編譯安裝;

ø  檢查狀態模組;--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; ##可对该页面的访问者进行过滤
   #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.測試語法;

#
[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.     輸出內容詳解;

第一行  active connections: 1  -活躍的連線數量,包括等待用戶端數0
第二行 server accepts handled requests —— 總共處理了1個連線, 成功建立1次握手, 總共處理了1個請求
第三行reading — 讀取客戶端的連線數,writing — 回應資料到客戶端的數量,waiting — 開啟keep-alive 的情況下,這個值等於active – (reading writing), 意思就是nginx 已經處理完正在等候下一次請求指令的駐留連線.

以上是Nginx怎麼設定檢測服務狀態的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:yisu.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!