這篇文章主要介紹“Nginx怎么配置檢測服務狀態”,在日常操作中,相信很多人在Nginx怎么配置檢測服務狀態問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Nginx怎么配置檢測服務狀態”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
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怎么配置檢測服務狀態”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。