CentOS8可以安装wordpress吗?

服务器

是的,CentOS 8 可以安装 WordPress。WordPress 是一个基于 PHP 和 MySQL 的内容管理系统(CMS),只要你的 CentOS 8 系统上具备以下基本环境组件,就可以顺利安装和运行 WordPress:


✅ 所需环境组件:

  1. Web服务器:Apache 或 Nginx
  2. 数据库服务器:MySQL 或 MariaDB
  3. PHP:建议 7.4 或以上版本(WordPress 官方推荐)
  4. PHP扩展模块:如 php-mysqlnd, php-curl, php-gd, php-mbstring 等

?️ 在 CentOS 8 上安装 WordPress 的步骤概览:

步骤一:安装 Apache(或 Nginx)

sudo dnf install httpd -y
sudo systemctl enable httpd
sudo systemctl start httpd

步骤二:安装 MariaDB(MySQL 替代)

sudo dnf install mariadb-server mariadb -y
sudo systemctl enable mariadb
sudo systemctl start mariadb

初始化数据库安全设置:

sudo mysql_secure_installation

步骤三:安装 PHP 及相关扩展

sudo dnf install php php-mysqlnd php-curl php-gd php-mbstring php-xml php-json -y

重启 Apache:

sudo systemctl restart httpd

安装完成后,可以创建一个 phpinfo.php 文件测试是否正常解析 PHP。

步骤四:配置 MariaDB 数据库

登录 MariaDB 并创建数据库和用户:

CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
exit;

步骤五:下载并配置 WordPress

cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
sudo cp -r wordpress /var/www/html/
sudo chown -R apache:apache /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress

步骤六:配置 WordPress

cd /var/www/html/wordpress
cp wp-config-sample.php wp-config.php
nano wp-config.php

修改以下字段为之前创建的数据库信息:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'your_password');

步骤七:访问 WordPress 安装页面

在浏览器中打开:

http://your_server_ip/wordpress

按照提示完成 WordPress 的安装流程(选择语言、设置管理员账号等)。


? 额外建议:

  • 启用防火墙允许 HTTP/HTTPS:

    sudo firewall-cmd --permanent --add-service=http
    sudo firewall-cmd --reload
  • 考虑使用 Let’s Encrypt 添加 SSL 证书增强安全性。

  • 如果使用 SELinux,确保权限配置正确或临时关闭进行测试:

    setsebool -P httpd_can_network_connect=1

✅ 总结:

组件 推荐
Web Server Apache 或 Nginx
DB Server MariaDB 或 MySQL
PHP 版本 7.4 或更高
PHP 模块 mysqlnd, curl, gd, mbstring, xml, json

只要你按上述步骤操作,完全可以在 CentOS 8 上成功部署 WordPress。

如果你需要我帮你写完整的脚本或配置文件,请告诉我!

未经允许不得转载:CDNK博客 » CentOS8可以安装wordpress吗?