編譯安裝 nginx的http_stub_status_module監控其運行狀態


步驟:

1 編譯nginx,加上參數 --with-http_stub_status_module

以我自己的編譯選項為例:

  #配置指令
  ./configure --prefix=/usr/local
    --user=nginx 
    --group=nginx
    --with-http_ssl_module --with-http_realip_module --http-client-body-temp-path=/usr/local/var/tmp/nginx/client --http-proxy-temp-path=/usr/local/var/tmp/nginx/proxy --http-fastcgi-temp-path=/usr/local/var/tmp/nginx/fcgi --http-scgi-temp-path=/usr/local/var/tmp/nginx/scgi --http-uwsgi-temp-path=/usr/local/var/tmp/nginx/uwsgi --with-http_geoip_module --with-http_stub_status_module 

2 修改nginx配置文件,添加監控狀態配置

在nginx.conf的server塊中添加如下代碼

location /nginx_status {
    # Turn on nginx stats stub_status on; # I do not need logs for stats access_log off; # Security: Only allow access from 192.168.1.100 IP # #allow 192.168.1.100; # Send rest of the world to /dev/null # #deny all; } 

這段代碼是加在默認的server里的,
假設默認server的配置為

listen       127.0.0.1:80; server_name 127.0.0.1; 

那么訪問nginx的狀態,就可以通過 curl 127.0.0.1/nginx_status訪問了

返回結果類似於:

Active connections: 1 server accepts handled requests 655 655 1985 Reading: 0 Writing: 1 Waiting: 0 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM