在 CentOS 上部署 WordPress 时,选择合适的版本主要涉及以下几个方面:
✅ 一、CentOS 版本推荐
目前主流的 CentOS 发行版有以下几种:
| CentOS 分支 | 状态 | 推荐用途 |
|---|---|---|
| CentOS Stream 8 | 稳定(2024年仍支持) | 开发/生产环境(推荐) |
| CentOS Stream 9 | 最新稳定版 | 新项目推荐使用 |
| CentOS 7 | 已于2024年6月停止维护 | 不推荐用于新项目 |
? 推荐版本:
- 首选:CentOS Stream 9
- 更现代的内核和软件包
- 支持较新的 PHP、MySQL、Nginx/Apache
- 次选:CentOS Stream 8
- 如果你需要更稳定的环境或已有旧系统兼容需求
✅ 二、WordPress 版本推荐
WordPress 官方会持续更新以适配最新的 PHP 和数据库版本。
当前推荐版本:
- 始终使用 最新稳定版 WordPress
- 截止 2025 年初,最新稳定版本为 6.7 左右
- 每个版本都会标注其所需的最低 PHP 和 MySQL 版本
✅ 三、PHP 版本要求(与 WordPress 兼容)
WordPress 官方推荐:
| WordPress 版本 | 最低 PHP 版本 | 推荐 PHP 版本 |
|---|---|---|
| WordPress 6.5+ | PHP 7.4 | PHP 8.1 / 8.2 |
| WordPress 6.0+ | PHP 7.4 | PHP 8.0 / 8.1 |
? 推荐安装 PHP 8.1 或 8.2(性能更好,安全性更高)
✅ 四、数据库推荐
- MySQL 8.0 或 MariaDB 10.6+
- CentOS Stream 8 默认提供 MariaDB 10.3+
- CentOS Stream 9 提供 MariaDB 10.9+
✅ 五、完整 LAMP/LNMP 组合推荐(适用于 CentOS Stream 9)
| 组件 | 推荐版本 |
|---|---|
| OS | CentOS Stream 9 |
| Web Server | Nginx 1.20+ / Apache 2.4+ |
| PHP | PHP 8.1 或 8.2 |
| DB | MariaDB 10.9 或 MySQL 8.0 |
| WordPress | 最新版(下载官方源码) |
✅ 安装建议流程(简要)
-
更新系统并安装 EPEL 和 Remi 仓库:
dnf install epel-release -y dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y -
启用 PHP 8.1 或 8.2 模块:
dnf module reset php dnf module enable php:8.2 -
安装 PHP 及扩展:
dnf install php php-cli php-mysqlnd php-gd php-curl php-mbstring php-xml unzip wget -y -
安装数据库(MariaDB):
dnf install mariadb-server mariadb -y systemctl start mariadb mysql_secure_installation -
安装 Web 服务器(Nginx/Apache):
dnf install nginx -y systemctl enable --now nginx -
下载并配置 WordPress:
cd /var/www wget https://wordpress.org/latest.tar.gz tar -zxvf latest.tar.gz chown -R apache:apache wordpress chmod -R 755 wordpress
✅ 总结推荐配置(生产环境)
| 项目 | 推荐版本 |
|---|---|
| 操作系统 | CentOS Stream 9 |
| Web 服务器 | Nginx 或 Apache |
| PHP | 8.1 或 8.2 |
| 数据库 | MariaDB 10.9 或 MySQL 8.0 |
| WordPress | 最新稳定版(从官网下载) |
如果你需要我帮你写一个完整的安装脚本或配置文档,也可以告诉我 ?
CDNK博客