“Laravel 在 Debian 上报错”这个话题太宽泛了,不同报错原因完全不同。下面我按最常见的几类情况给你一个排查清单,你可以对照看是哪一种,或者直接把具体报错信息贴出来。
Laravel 对 PHP 版本要求很高:
| Laravel | PHP |
|---|---|
| 8.x | ≥ 7.3 |
| 9.x | ≥ 8.0 |
| 10.x | ≥ 8.1 |
| 11.x | ≥ 8.2 |
检查:
php -v
常见报错:
Your requirements could not be resolved to an installable set of packages.
✅ 解决:
apt install php8.1 php8.1-cli php8.1-common
Laravel 必需扩展:
php-mbstring
php-xml
php-bcmath
php-curl
php-zip
php-mysql / php-pgsql
php-gd
php-intl
报错示例:
Class 'PDO' not found
✅ 解决:
apt install php8.1-mysql php8.1-xml php8.1-mbstring php8.1-bcmath php8.1-curl php8.1-zip
报错:
The stream or file "/var/www/laravel/storage/logs/laravel.log" could not be opened
✅ 解决:
chown -R www-data:www-data /var/www/laravel
chmod -R 755 /var/www/laravel/storage
chmod -R 755 /var/www/laravel/bootstrap/cache
报错:
No application encryption key has been specified.
✅ 解决:
cp .env.example .env
php artisan key:generate
报错:
PHP Fatal error: Allowed memory size exhausted
✅ 解决:
COMPOSER_MEMORY_LIMIT=-1 composer install
典型现象:
index.php 直接下载✅ Nginx 示例:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
aa-status
php -v
php artisan --version
tail -n 50 storage/logs/laravel.log
你可以直接回复:
cat /etc/os-release)我可以一步一步帮你修到能跑 ✅