开启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

相关内容