在 Debian 上监控 Apache(通常是 apache2)可以从系统层、服务层、Web 层、日志层、性能层几个维度来做。下面按“从简单到专业”给你一套实用方案。
systemctl status apache2
开机自启检查:
systemctl is-enabled apache2
重启 / 重载:
systemctl restart apache2
systemctl reload apache2
ss -ant | grep :80 | wc -l
ss -ant | grep :443 | wc -l
ps aux | grep apache2
mod_statusa2enmod status
编辑配置(Debian 通常在 /etc/apache2/mods-enabled/status.conf):
<Location "/server-status">
SetHandler server-status
Require local
# 如需远程
# Require ip 1.2.3.4
</Location>
启用扩展状态:
ExtendedStatus On
重启:
systemctl restart apache2
访问:
http://localhost/server-status
可看到:
tail -f /var/log/apache2/access.log
tail -f /var/log/apache2/error.log
awk '{print $1}' /var/log/apache2/access.log | sort | uniq -c | sort -nr | head
top
htop
free -h
df -h
ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | grep apache2
适合服务器集群。
node_exporter:系统指标apache_exporter:Apache 状态指标Prometheus + GrafanaApache Exporter 示例:
apache_exporter --scrape_uri=http://localhost/server-status?auto
monitapt install monit
监控 apache2 进程,自动重启
✅ 必须关注:
systemctl status apache2
ss -ant | grep :80 | wc -l
tail -n 50 /var/log/apache2/error.log
curl -I http://localhost
如果你愿意,可以告诉我:
我可以直接给你一套可复制的配置。