首页 小编推荐 正文
  • 本文约1207字,阅读需6分钟
  • 64597
  • 5

CentOS 7快速搭建WordPress教程

温馨提示:本文最后更新于2026年6月7日 12:30,若内容或图片失效,请在下方留言或联系博主。
摘要

安装CentOS 7并搭建WordPress需要以下几个步骤:

  1. 更新系统
    使用root用户登录CentOS 7,执行以下命令更新系统:

    yum update -y
  2. 安装Apache
    安装Apache web服务器:

    
    yum install httpd -y
    `...

安装CentOS 7并搭建WordPress需要以下几个步骤:

  1. 更新系统
    使用root用户登录CentOS 7,执行以下命令更新系统:

    yum update -y
  2. 安装Apache
    安装Apache web服务器:

    yum install httpd -y

    启动Apache服务并设置开机启动:

    systemctl start httpd
    systemctl enable httpd
  3. 安装MySQL
    安装MySQL数据库:

    yum install mysql-server -y

    启动MySQL服务并设置开机启动:

    systemctl start mysqld
    systemctl enable mysqld

    运行安全脚本以设置MySQL密码:

    mysql_secure_installation
  4. 安装PHP
    安装PHP和必要的模块:

    yum install php php-mysql php-gd php-xml php-mbstring php-json -y
  5. 配置Apache
    编辑Apache配置文件:

    vi /etc/httpd/conf/httpd.conf

    确保以下行存在:

    ServerName your_domain_name:80

    保存并退出,然后重启Apache服务:

    systemctl restart httpd
  6. 下载WordPress
    从官方网站下载WordPress:

    cd /var/www/html
    wget https://wordpress.org/latest.tar.gz
    tar -xvzf latest.tar.gz
    mv wordpress/* .
    rm -rf wordpress latest.tar.gz
  7. 创建MySQL数据库
    登录MySQL:

    mysql -u root -p

    创建数据库和用户:

    CREATE DATABASE wordpress;
    CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
  8. 配置WordPress
    复制示例配置文件:

    cp wp-config-sample.php wp-config.php

    编辑配置文件:

    vi wp-config.php

    修改以下内容:

    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wordpressuser');
    define('DB_PASSWORD', 'password');
    define('DB_HOST', 'localhost');

    保存并退出。

  9. 设置文件权限
    设置文件权限:

    chown -R apache:apache /var/www/html
    chmod -R 755 /var/www/html
  10. 访问WordPress
    在浏览器中访问:

    http://your_server_ip

    按照提示完成WordPress安装。

32119 人点赞
评论