在 Debian 上调试 Laravel 错误,通常可以从 环境配置、日志、异常信息、PHP 配置、服务器配置 几个方面入手。下面按常见场景给你一份实用排查指南。
php artisan --version
php artisan env
常见环境:
local(开发,推荐开启调试)production(生产,调试信息应关闭).envAPP_ENV=local
APP_DEBUG=true
php artisan config:clear
php artisan cache:clear
⚠️ 生产环境不要开启 APP_DEBUG=true
tail -f storage/logs/laravel.log
常见错误:
sudo chown -R www-data:www-data storage
sudo chmod -R 775 storage
如果你用 php artisan serve:
sudo chown -R $USER:$USER storage
tail -f /var/log/php8.2-fpm.log
# 或
tail -f /var/log/apache2/error.log
编辑:
/etc/php/8.2/fpm/php.ini
# 或
/etc/php/8.2/cli/php.ini
设置:
display_errors = On
error_reporting = E_ALL
log_errors = On
重启 PHP-FPM:
sudo systemctl restart php8.2-fpm
tail -f /var/log/nginx/error.log
常见原因:
root 路径错误index index.php 没配置tail -f /var/log/apache2/error.log
✅ 检查:
storage/logs/laravel.log
php artisan route:list
php artisan migrate
检查 .env:
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=xxx
DB_USERNAME=xxx
DB_PASSWORD=xxx
dd() / dump()dd($data);
dump($data);
访问错误页面时,Laravel 会显示:
sudo chown -R www-data:www-data bootstrap/cache
sudo chown -R www-data:www-data storage
sudo chmod -R 775 bootstrap/cache storage
1. 打开 APP_DEBUG=true
2. 访问页面
3. 看 storage/logs/laravel.log
4. 看 PHP / Nginx / Apache 日志
5. 检查权限
如果你愿意,可以把 具体错误信息 / 页面提示 / 日志内容 贴出来,我可以直接帮你定位是哪一类问题(PHP、Laravel、权限、数据库、服务器)。