在 Debian 上安装并运行 Laravel,通常需要以下几类依赖,按「系统级 → PHP → 数据库 → 工具」来说明。
sudo apt update
sudo apt install -y curl wget git unzip software-properties-common ca-certificates lsb-release
Laravel 对 PHP 版本有要求(以 Laravel 10/11 为例,需 PHP ≥ 8.1)
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y php8.2 php8.2-cli \
php8.2-common php8.2-mbstring php8.2-xml \
php8.2-curl php8.2-zip php8.2-gd php8.2-mysql \
php8.2-bcmath php8.2-intl php8.2-fpm
✅ Laravel 必需扩展总结:
php-climbstringxmlcurlzipbcmathtokenizer(PHP 自带)json(PHP 自带)openssl(PHP 自带)curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer --version
sudo apt install -y mariadb-server
# 或
sudo apt install -y mysql-server
sudo apt install -y postgresql postgresql-contrib php8.2-pgsql
sudo apt install -y nginx
sudo apt install -y apache2 libapache2-mod-php8.2
sudo apt install -y redis-server php8.2-redis
sudo apt install -y supervisor
sudo apt install -y nodejs npm
✅ 最少需要:
✅ 生产环境建议:
如果你愿意,我可以:
你用的是 Debian 几?Laravel 几?本地还是服务器?