[root@howtoing ~]# vi /etc/httpd/conf/httpd.conf搜索“mod_status的 ”单词或直到找到包含线不断向下滚动。
#LoadModule status_module modules/mod_status.so如果你在“的LoadModule”的开头看到一个“#”字符,这意味着mod_status的是禁用的。 删除'#'来启用mod_status模块。
LoadModule status_module modules/mod_status.so
# 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 .example.com #</Location>在上面的部分,根据您的需求为注释Location指令 ,SetHandler和目录限制线。 例如,我使用简单的订单允许 , 拒绝和它允许所有 。
<Location /server-status> SetHandler server-status Order allow,deny Deny from all Allow from all </Location>注 :以上配置是默认的Apache网站(一个网站)的默认配置。 如果你已经创建一个或多个Apache的虚拟主机 ,上面的配置将不会起作用。 因此,基本上,您需要为您在Apache中配置的任何域定义每个虚拟主机的相同配置。例如,mod_status的虚拟主机配置如下所示。
<VirtualHost *:80> ServerAdmin howtoing@example.com DocumentRoot /var/www/html/example.com ServerName example.com ErrorLog logs/example.com-error_log CustomLog logs/example.com-access_log common <Location /server-status> SetHandler server-status Order allow,deny Deny from all Allow from example.com </Location> </VirtualHost>
# 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
[root@howtoing ~]# httpd -t Syntax OK有一次,你得到的语法是OK,你可以能够重新启动httpd服务。
[root@howtoing ~]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
http://serveripaddress/server-status OR http://serev-hostname/server-status你会看到类似与ExtendedStatus以下页面启用了一些东西。 在上面的快照,你可以看到一个HTML界面,显示有关服务器正常运行的所有信息, 进程ID与其各自的客户端 ,网页,他们试图访问。 它还显示了用于显示状态的所有缩写的含义和用法,这有助于我们更好地理解情况。 您也可以刷新页面每次秒(比如5秒 ),以查看更新的统计数据。 要设置自动化更新,请加“? 刷新= N”的网址的结尾。 其中N可以用秒数来代替您希望您的网页得到刷新。
http://serveripaddress/server-status/?refresh=5
# yum install links OR # yum install lynx一旦你安装了,你可以通过使用以下命令在终端上获得相同的统计信息。
[root@howtoing ~]# links http://serveripaddress/server-status OR [root@howtoing ~]# lynx http://serveripaddress/server-status OR [root@howtoing ~]# /etc/init.d/httpd fullstatus
Apache Server Status for localhost Server Version: Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 Server Built: Aug 13 2013 17:29:28 -------------------------------------------------------------------------- Current Time: Tuesday, 14-Jan-2014 04:34:13 EST Restart Time: Tuesday, 14-Jan-2014 00:33:05 EST Parent Server Generation: 0 Server uptime: 4 hours 1 minute 7 seconds Total accesses: 2748 - Total Traffic: 9.6 MB CPU Usage: u.9 s1.06 cu0 cs0 - .0135% CPU load .19 requests/sec - 695 B/second - 3658 B/request 1 requests currently being processed, 4 idle workers .__.__W... Scoreboard Key: "_" Waiting for Connection, "S" Starting up, "R" Reading Request, "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, "C" Closing connection, "L" Logging, "G" Gracefully finishing, "I" Idle cleanup of worker, "." Open slot with no current process Srv PID Acc M CPU SS Req Conn Child Slot Client VHost Request 0-0 - 0/0/428 . 0.30 5572 0 0.0 0.00 1.34 127.0.0.1 5.175.142.66 OPTIONS * HTTP/1.0 GET 1-0 5606 0/639/639 _ 0.46 4 0 0.0 2.18 2.18 115.113.134.14 5.175.142.66 /server-status?refresh=5 HTTP/1.1 GET 2-0 5607 0/603/603 _ 0.43 0 0 0.0 2.09 2.09 115.113.134.14 5.175.142.66 /server-status?refresh=5 HTTP/1.1 3-0 - 0/0/337 . 0.23 5573 0 0.0 0.00 1.09 127.0.0.1 5.175.142.66 OPTIONS * HTTP/1.0 GET 4-0 5701 0/317/317 _ 0.23 9 0 0.0 1.21 1.21 115.113.134.14 5.175.142.66 /server-status?refresh=5 HTTP/1.1 GET 5-0 5708 0/212/213 _ 0.15 6 0 0.0 0.85 0.85 115.113.134.14 5.175.142.66 /server-status?refresh=5 HTTP/1.1 6-0 5709 0/210/210 W 0.16 0 0 0.0 0.84 0.84 127.0.0.1 5.175.142.66 GET /server-status HTTP/1.1 7-0 - 0/0/1 . 0.00 5574 0 0.0 0.00 0.00 127.0.0.1 5.175.142.66 OPTIONS * HTTP/1.0 -------------------------------------------------------------------------- Srv Child Server number - generation PID OS process ID Acc Number of accesses this connection / this child / this slot M Mode of operation CPU CPU usage, number of seconds SS Seconds since beginning of most recent request Req Milliseconds required to process most recent request Conn Kilobytes transferred this connection Child Megabytes transferred this child Slot Total megabytes transferred this slot -------------------------------------------------------------------------- Apache/2.2.15 (CentOS) Server at localhost Port 80
关注云架构公众号
Linux入门
QQ交流群:308781113