在 Debian 下运行 Laravel 出错,一般按**“看日志 → 定位环境 → 逐项排查”**的思路来处理。下面给你一套实战排查清单。
tail -f storage/logs/laravel.log
APP_DEBUG=true
php artisan <命令>
看终端报错信息即可。
Laravel 对 PHP 有要求(如 Laravel 10 需要 PHP 8.1+)
查看版本:
php -v
Debian 默认可能还是 PHP 7.4,需要装新版本:
sudo apt install php8.1 php8.1-cli php8.1-fpm php8.1-mysql php8.1-mbstring php8.1-xml php8.1-curl
常见缺:
安装示例:
sudo apt install php8.1-mbstring php8.1-xml php8.1-curl php8.1-zip php8.1-gd php8.1-bcmath
检查扩展:
php -m | grep -E 'mbstring|xml|curl'
Laravel 需要写:
storagebootstrap/cache修复权限:
sudo chown -R www-data:www-data /var/www/laravel
sudo chmod -R 755 storage bootstrap/cache
如果你是 CLI 运行:
sudo chown -R $USER:www-data storage bootstrap/cache
composer install
composer update
报内存不足:
php -d memory_limit=-1 composer install
public示例:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
cp .env.example .env
php artisan key:generate
清缓存:
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php -v
php -m
tail -n 50 storage/logs/laravel.log
composer diagnose
php artisan --version
你可以直接贴:
cat /etc/os-release)php artisan --version)我可以按你的具体错误一行一行帮你修。