在 CentOS 系统中,Apache 通常使用 httpd
作为服务名称。要监控 Apache 的状态,您可以使用以下方法:
sudo systemctl status httpd
这将显示 Apache 服务的详细状态信息,包括是否正在运行、最近的日志条目等。
sudo systemctl status httpd | grep "Active:"
这将显示 Apache 服务已经运行的时间。
Apache 的错误日志通常位于 /var/log/httpd/error_log
。您可以使用以下命令查看错误日志:
sudo tail -f /var/log/httpd/error_log
这将实时显示错误日志的最新条目。您可以根据需要修改文件路径以查看其他日志文件。
首先,确保已启用 mod_status 模块。在 /etc/httpd/conf.d/status.conf
文件中取消以下行的注释:
<Location "/server-status">
SetHandler server-status
Require host example.com # 替换为您的服务器 IP 地址或域名
</Location>
然后,重启 Apache 服务以应用更改:
sudo systemctl restart httpd
现在,您可以通过访问 http://your_server_ip_or_domain/server-status
来查看 Apache 的状态页面。请注意,您可能需要根据实际情况修改 URL 中的服务器 IP 地址或域名。
在状态页面上,您可以查看服务器的运行时间、当前活动连接数、请求处理速度等信息。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>