在 Debian 下运行 Laravel 报错的“原因很多”,通常可以按 报错类型 来快速定位。下面给你一套通用排查流程 + 常见错误及解决办法,你可以对照看。
tail -f storage/logs/laravel.log
或访问页面时打开:
APP_DEBUG=true
Laravel 需要写 storage 和 bootstrap/cache
sudo chown -R www-data:www-data /var/www/your-project
sudo chmod -R 755 storage bootstrap/cache
如果你是 CLI 运行:
sudo chown -R $USER:www-data storage
Laravel 10+ 需要 PHP 8.1+
检查:
php -v
php -m | grep -E "mbstring|xml|ctype|json|tokenizer|bcmath|openssl"
缺扩展就装:
sudo apt install php8.2-mbstring php8.2-xml php8.2-bcmath php8.2-curl
composer install
composer dump-autoload
The stream or file "/storage/logs/laravel.log" could not be opened✅ 权限问题
chmod -R 775 storage
chown -R www-data:www-data storage
SQLSTATE[HY000] [2002] Connection refused✅ 数据库问题
sudo systemctl status mysql
.env 检查:
DB_HOST=127.0.0.1
DB_PORT=3306
Class "XXX" not found✅ 自动加载坏了
composer dump-autoload
Permission denied (public key)(Git/Deploy)ssh-keygen -t ed25519
cat ~/.ssh/id_ed25519.pub
加到 Git 服务器
sudo apt install php8.2-fpm
sudo systemctl restart php8.2-fpm
sudo systemctl restart nginx
你可以把 具体报错信息(哪怕是截图文字)发给我,例如:
laravel.log 内容php artisan 报错我可以精确到哪一行配置或命令帮你改。
你现在是 本地 / 服务器 / Docker 环境?