在Debian上监控Laravel应用的性能,可以通过以下几个步骤来实现:
New Relic是一个强大的应用性能监控(APM)工具,可以提供详细的性能数据。
安装New Relic PHP Agent:
composer require newrelic/php-agent
配置newrelic.ini
:
在/etc/php/7.x/cli/conf.d/
目录下创建或编辑newrelic.ini
文件,添加你的New Relic许可证密钥:
newrelic.appname = "Your Application Name"
newrelic.license = "your_license_key"
重启PHP-FPM或Apache:
sudo systemctl restart php7.x-fpm
# 或者
sudo systemctl restart apache2
Datadog是另一个流行的APM工具,提供详细的监控和分析功能。
安装Datadog PHP Agent:
composer require datadog/php-datadog-agent
配置datadog.yaml
:
在/etc/datadog-agent/datadog.yaml
文件中添加你的Datadog API密钥和应用密钥:
datadog:
api_key: "your_datadog_api_key"
app_key: "your_datadog_app_key"
重启Datadog Agent:
sudo systemctl restart datadog-agent
Laravel Telescope是一个内置的性能监控工具,可以记录请求、异常、数据库查询等。
安装Telescope:
composer require laravel/telescope
php artisan telescope:install
发布配置文件:
php artisan vendor:publish --provider="Laravel\Telescope\TelescopeServiceProvider" --tag=telescope-config
运行迁移:
php artisan migrate
启动队列监听器(可选):
php artisan telescope:queue:listen
访问Telescope界面:
打开浏览器,访问http://your-app-url/telescope
。
htop
是一个交互式的进程查看器,可以帮助你监控系统资源的使用情况。
安装htop:
sudo apt update
sudo apt install htop
运行htop:
htop
top
是另一个常用的系统监控工具。
top
Laravel的日志文件位于storage/logs/laravel.log
,你可以使用tail
命令实时查看日志:
tail -f storage/logs/laravel.log
除了上述工具,你还可以考虑使用其他第三方监控服务,如Prometheus、Grafana等,来监控你的Laravel应用。
通过这些步骤,你可以在Debian上有效地监控Laravel应用的性能。