在 Debian 下运行 Laravel 报错,第一步永远是看错误信息和日志,不能盲猜。下面给你一套「通用排查流程 + 常见报错速查表」,基本能解决 90% 的问题。
APP_DEBUG=truestorage/logs/laravel.log
tail -100 storage/logs/laravel.log
/var/log/nginx/error.log/var/log/apache2/error.log报错示例
The stream or file "/var/www/laravel/storage/logs/laravel.log" could not be opened
解决
sudo chown -R www-data:www-data /var/www/laravel
sudo chmod -R 755 /var/www/laravel
sudo chmod -R 775 storage bootstrap/cache
报错
Your requirements could not be resolved
或
Composer detected issues in your platform
查看版本
php -v
Debian 安装 PHP 8.1/8.2
sudo apt install php8.2 php8.2-cli php8.2-fpm php8.2-mysql php8.2-mbstring php8.2-xml php8.2-curl
常见缺失
安装
sudo apt install php8.2-mbstring php8.2-xml php8.2-curl php8.2-zip php8.2-bcmath
重启:
sudo systemctl restart php8.2-fpm
composer install
常见问题:
重装 vendor
rm -rf vendor
composer install
cp .env.example .env
php artisan key:generate
正确 root
root /var/www/laravel/public;
重写规则
location / {
try_files $uri $uri/ /index.php?$query_string;
}
php artisan storage:link
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
请把以下信息贴出来:
cat /etc/os-release)storage/logs/laravel.log 报错片段我可以直接告诉你哪一行错了、怎么改。