開啟server-status失敗,開啟server-status

來源:互聯網
上載者:User

開啟server-status失敗,開啟server-status

近日在配置監控寶的apache監控老是出錯,經過研究發現如下:

下面先做一些簡要的介紹,以防以後查看之用。

一、server-status是什嗎?
二、如何開啟server-status?
三、server-status的內容介紹
四、如何開啟server-status的即時監控?
五、如何保護server-status?
六、FAQ
七、參考閱讀

一、server-status是什嗎?
server-status是Apache查看狀態的一個功能模組,在Apache 1.3.2及以後的版本提供

二、如何開啟server-status?
如果Apache的設定檔,比如件httpd.conf或者extra/httpd-info.conf中有這麼一條語句的話,你就要注意了
LoadModule status_module modules/mod_status.so
如果這句語句前沒有#注釋的話,說明該模組已經被載入

如果是linux平台的,在Apache編譯的時候加上了–enable-module=so也表明apache支援server-status

,我測試了好多次直接在httpd.conf裡面加mod_status.so都是失敗,最後包含了/www/apche/conf/extra/httpd-info.conf 進到httpd.conf ,如下語句:

Include /apache/httpd-2.2.22/conf/extra/httpd-info.conf

  要使用絕對位址以防出錯。

然後在/www/apche/conf/extra/httpd-info.conf開啟ExtendedStatus On,把前面的#去掉。展示部分內容:

# Change the ".example.com" to match your domain to enable.<Location /server-status>    SetHandler server-status    Order deny,allow    Deny from all    Allow from .xxx.com</Location>## ExtendedStatus controls whether Apache will generate "full" status# information (ExtendedStatus On) or just basic information (ExtendedStatus# Off) when the "server-status" handler is called. The default is Off.#ExtendedStatus On

  如何保護安全下面會談到。

三、server-status的內容介紹

如果你開啟ExtendedStatus On的話,你可以看到每個串連的IP資訊,狀態資訊,其中對於狀態資訊解釋如下:

_:等待連結中。
S:啟動中。
R: 正在讀取要求。
W:正在送出回應。
K:處於保持聯機的狀態。
D:正在尋找 DNS。
C:正在關閉連結。
L:正在寫入記錄檔案。
G:進入正常結束程式中。
I:處理閑置。
.:尚無此程式。

四、如何開啟server-status的即時監控?

so easy!

代碼格式:server-status?refresh=N
N為需要幾秒重新整理一次

比如:http://www.xxxxxxxx.com/server-status?refresh=10 (www.xxxxxxxx.com換成你自己網域名稱)

五、如何保護server-status?
你也不想你的server-status一直被別人調用吧。所以附上保護代碼:

你可以將預設的

SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 你允許的IP地址或網域名稱

ExtendedStatus On

修改為

SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 你允許的IP地址或網域名稱

ExtendedStatus On

這樣的話,你就需要通過http://你允許的IP地址或網域名稱/hahaha-server-status的方式來訪問了。

簡要說明:
ExtendedStatus On表示的是訪問時能看到詳細的請求資訊,
注意:該設定僅能用於全域設定,不能在特定的虛擬機器主機中開啟或關閉。
啟用擴充狀態資訊將會導致伺服器運行效率降低。
Deny from表示禁止訪問的地址;
Allow from表示允許訪問的地址;

六、FAQ

1,如上所操作還是失敗,何故?

那麼可以查看下 httpd -l裡面啟用了本模組,如果沒有的話可要把該模組給編譯進到apache裡面。以後有時間再寫下怎麼編譯吧。

七、參考閱讀

http://httpd.apache.org/docs/2.2/mod/mod_status.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.