你这个问题太宽泛了,我需要先说明:Laravel 在 Linux 上报错的原因非常多,不同错误原因完全不同。下面我分常见类型 + 排查方法给你一个系统性的排查思路,你对照一下自己是哪一种。
报错类似:
The stream or file "/storage/logs/laravel.log" could not be openedfailed to open stream: Permission denied✅ 解决:
sudo chown -R www-data:www-data /var/www/your_project
sudo chmod -R 755 storage bootstrap/cache
报错类似:
Composer detected issues in your platformParse error: syntax error✅ 检查:
php -v
Laravel 版本要求:
报错类似:
Class not foundCommand "serve" is not defined✅ 解决:
composer install
npm install && npm run build
报错类似:
No application encryption key has been specified✅ 解决:
cp .env.example .env
php artisan key:generate
常见错误:
File not found✅ Nginx 必须指向:
root /var/www/your_project/public;
✅ 清缓存:
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
tail -f storage/logs/laravel.log
.env 中:
APP_DEBUG=true
请把以下信息发给我:
只要贴出报错,我可以直接告诉你原因 + 解决方案。