首先 server-status和server-info 依赖于/usr/local/apache2/conf/extra/httpd-info.conf
于是去/usr/local/apache2/conf/extra/httpd-info.conf中修改配置,可以修改如下:
#
# Get information about the requests being processed by the server
# and the configuration of the server.
#
# Required modules: mod_status (for the server-status handler),
# mod_info (for the server-info handler)
#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Change the ".example.com" to match your domain to enable.
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost
</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
#
# Allow remote server configuration reports, with the URL of
# http://servername/server-info (requires that mod_info.c be loaded).
# Change the ".example.com" to match your domain to enable.
#
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from localhost
</Location>
本地测试的情况可以设置为监控localhost,另外要将ExtendedStatus On打开
然后我们需要保证apache已经安装mod_status和mod_info模块,可以用以下命令查看:
apache2 -l 或者 httpd -l
得到结果如下:
root@junjie :/home/andy/Downloads/httpd-2.2.25# apache -l
Compiled in modules:
core.c
mod_authn_file.c
mod_authn_default.c
mod_authz_host.c
mod_authz_groupfile.c
mod_authz_user.c
mod_authz_default.c
mod_auth_basic.c
mod_cache.c
mod_mem_cache.c
mod_include.c
mod_filter.c
mod_log_config.c
mod_env.c
mod_mime_magic.c
mod_expires.c
mod_headers.c
mod_usertrack.c
mod_unique_id.c
mod_setenvif.c
mod_version.c
mod_proxy.c
mod_proxy_connect.c
mod_proxy_ftp.c
mod_proxy_http.c
mod_proxy_scgi.c
mod_proxy_ajp.c
mod_proxy_balancer.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_asis.c
mod_info.c
mod_negotiation.c
mod_dir.c
mod_alias.c
mod_rewrite.c
mod_so.c
可以看到已经安装加载的apache模块
如果结果中没有mod_status.so和mod_info.so,那么你需要重新编译安装apache,例如:
./configure --enable-module=so --enable-info
重新编译安装apache,注意make clean
如果上面一切执行完毕之后,我们就需要修改配置:httpd.conf
# Real-time info on requests and configuration
Include conf/extra/httpd-info.conf
然后我们重启apache就可以访问了:
http://localhost/server-status
2. 通过http://<servername>/server-status?refresh=1,可每秒刷新一次页面。 3. 通过http://<servername>/server-status?auto可看到如下信息: