以下是Ubuntu下监控PHP的常用方法:
sudo apt install htop # 安装htop
htop
ps aux | grep php
sudo systemctl status php-fpm
sudo tail -f /var/log/apache2/access.log # 实时查看Apache访问日志
sudo less +F /var/log/nginx/error.log # 实时查看Nginx错误日志
memory_get_usage()、getrusage()等函数获取脚本资源占用。根据需求选择工具:简单监控可用命令行或Monit;复杂场景推荐第三方APM工具(如New Relic)或日志分析方案(如ELK Stack)。