原标题:在Ubuntu中使用mod_status模块监视Apache性能
来自:Linux迷
网址:https://www.linuxmi.com/ubuntu-mod_status-apache.html
虽然您可以通过查看Apache日志文件来获得有关您的Web服务器的信息,比如活动连接,但是您可以通过启用mod_status模块来获得Web服务器性能的非常详细的概述。
什么是mod_status模块?
mod_status模块是一个Apache模块,它允许用户在纯HTML页面上访问关于Apache性能的详细信息。实际上,Apache维护了自己的服务器状态页面供一般公众查看。
你可以通过下面的地址查看Apache (Ubuntu)的状态:
https://apache.org/server-status
Apache mod_status使它有可能提供一个包含信息的纯HTML页面,如:
服务器版本
UTC中的当前日期和时间
服务器正常运行时间
服务器负载
总交通量
传入请求总数
Web服务器的CPU使用率
与各自客户的PID等等。
现在让我们来改变一下,看看如何获得关于apacheweb服务器的最新统计数据。
测试环境
操作系统 Ubuntu 20.04
应用: Apache HTTP server
版本: 2.4.41
IP地址: 192.168.150.135
文档目录: /var/www/html
为Ubuntu中的 Apache 启用 mod_status
默认情况下,Apache已经启用了mod_status模块。您可以通过运行ls命令检查mods_enabled目录来验证这一点,如下所示:
linuxmi@linuxmi:~/www.linuxmi.com$ ls /etc/apache2/mods-enabled
确保status.conf 和 status.load文件出现。如果没有,你需要通过调用命令来启用mod_status模块:
linuxmi@linuxmi:~/www.linuxmi.com$ sudo /usr/sbin/a2enmod status
在Apache Ubuntu中配置mod_status
如前所述,mod_status已经启用。但是,访问服务器状态页需要进行额外的调整。为此,您需要修改status.conf文件。
linuxmi@linuxmi:~/www.linuxmi.com$ sudo vim /etc/apache2/mods-enabled/status.conf
设置Require ip指令,以反映您将从其中访问服务器的机器的ip地址。
保存更改并重新启动Apache,使更改生效,以确认状态如下:
linuxmi@linuxmi:~/www.linuxmi.com$ sudo systemctl restart apache2
然后验证Apache的状态,确保它启动并运行。
linuxmi@linuxmi:~/www.linuxmi.com$ sudo systemctl status apache2
然后,浏览Web服务器的URL,如下所示。
http://server-ip/server-status
您将得到一个状态HTML页面,其中显示Apache的大量信息和一组统计数据,如图所示。
注意:要在给定的时间间隔(例如5秒)后刷新页面,请附加“?refresh=5”在URL的结尾。
http://server-ip/server-status?refresh=5
与前面的纯静态HTML页面相比,这提供了更好的服务器性能监视能力。
以上就是mod_status模块的全部内容。请继续关注LinuxMi.com。返回搜狐,查看更多
责任编辑: