在 Debian + LNMP(Linux + Nginx + MySQL/MariaDB + PHP) 环境下,监控通常分为 系统层、服务层、应用层。下面给你一套从简单到专业的可落地方案。
top / htop
free -h
df -h
iostat -x 1
systemctl status nginx
systemctl status mysql
systemctl status php8.2-fpm
server {
location /nginx_status {
stub_status on;
allow 127.0.0.1;
deny all;
}
}
查看:
curl http://127.0.0.1/nginx_status
关注指标:
SHOW STATUS LIKE 'Threads_%';
SHOW PROCESSLIST;
SHOW GLOBAL STATUS;
慢查询:
SHOW VARIABLES LIKE 'slow_query%';
systemctl status php8.2-fpm
开启 status:
pm.status_path = /status
Nginx 中:
location ~ ^/(status)$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
tail -f /var/log/nginx/access.log
tail -f /var/log/nginx/error.log
tail -f /var/log/mysql/error.log
goaccess access.log
bash <(curl -Ss https://my-netdata.io/kickstart.sh)
✅ 自动监控 CPU、内存、Nginx、MySQL、PHP
✅ Web 界面,零配置
组件:
适合:
| 场景 | 推荐 |
|---|---|
| 个人服务器 | Netdata |
| 小公司 | Netdata + 日志 |
| 生产环境 | Prometheus + Grafana |
| 多台服务器 | Zabbix / Prometheus |
如果你愿意,可以告诉我:
我可以直接帮你 写一套完整监控配置。