Debian下LNMP版本选择建议
一 选择原则
二 组件版本建议
| 组件 | 推荐选择 | 说明 |
|---|---|---|
| Linux(Debian) | Debian 12(Bookworm)稳定版 | 稳定、安全更新周期长,适合生产 |
| Nginx | 系统仓库的最新稳定版 | 性能与功能迭代稳定,配置与生态成熟 |
| MariaDB | 系统仓库的最新稳定版(如 10.11 系列) | 与Debian 12打包版本匹配,兼容性与维护性更好 |
| MySQL | 系统仓库的最新稳定版(如 8.0 系列) | 若应用强依赖MySQL特性再选,注意与生态的兼容性 |
| PHP | 优先 8.2;如需兼容旧项目再用 7.4/8.0/8.1 | 新项目建议8.2;旧项目按兼容性选择,避免过旧版本 |
三 快速安装与基础配置要点
sudo apt update && sudo apt upgrade -ysudo apt install nginx -y && sudo systemctl enable --now nginxsudo apt install mariadb-server mariadb-client -y && sudo systemctl enable --now mariadb && sudo mysql_secure_installationsudo apt install mysql-server -y && sudo systemctl enable --now mysql && sudo mysql_secure_installationsudo apt install php-fpm php-mysql php-gd php-mbstring php-curl php-xml -y && sudo systemctl enable --now php8.2-fpmindex index.php index.html;location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }sudo nginx -t && sudo systemctl reload nginxsudo systemctl status nginx mariadb php8.2-fpm/var/www/html/info.php输出phpinfo();确认版本与模块。四 升级与维护策略
sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -ysudo apt install --only-upgrade nginx mariadb-server php8.2-fpmsources.list中的bullseye替换为bookworm;sudo apt update && sudo apt full-upgrade -y && sudo reboot;