京东云服务器如何安装WordPress?

在京东云服务器上安装 WordPress,可以按照以下步骤进行操作。这里假设你使用的是 Linux 系统(如 CentOS 或 Ubuntu),并且已经拥有一个京东云的 ECS 实例。


🧩 准备工作

  1. 登录京东云控制台

    • 购买并配置好云服务器(ECS)
    • 开放安全组端口:80(HTTP)、443(HTTPS)、22(SSH)
  2. 连接到服务器
    使用 SSH 连接到你的京东云服务器:

    ssh root@你的服务器公网IP

✅ 安装环境(LNMP 或 LAMP)

WordPress 需要支持 PHP 和 MySQL 的环境,推荐使用 LNMP(Linux + Nginx + MySQL + PHP)架构。

1. 安装 Nginx(或 Apache)

CentOS:

yum install nginx -y
systemctl start nginx
systemctl enable nginx

Ubuntu:

sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

2. 安装 MySQL / MariaDB

CentOS:

yum install mariadb-server mariadb -y
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation

Ubuntu:

sudo apt install mysql-server -y
sudo mysql_secure_installation

3. 安装 PHP 及扩展

WordPress 需要一些 PHP 扩展,例如 php-mysql, php-curl 等。

CentOS(使用 EPEL 和 Remi 源):

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum install yum-utils -y
yum-config-manager --enable remi-php74
yum install php php-fpm php-mysqlnd php-curl php-gd php-mbstring php-xml php-zip -y

Ubuntu:

sudo apt install php php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-zip -y

启动 PHP-FPM:

systemctl start php-fpm
systemctl enable php-fpm

🌐 配置 Nginx 虚拟主机(可选)

创建一个新的站点配置文件,例如 /etc/nginx/conf.d/wordpress.conf

server {
    listen 80;
    server_name your_domain;

    root /var/www/html/wordpress;
    index index.php index.html;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ .php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }

    location ~ /.ht {
        deny all;
    }
}

然后重启 Nginx:

systemctl restart nginx

📦 下载并安装 WordPress

cd /tmp
wget https://cn.wordpress.org/latest-zh_CN.tar.gz
tar -zxvf latest-zh_CN.tar.gz
mv wordpress /var/www/html/
chown -R apache:apache /var/www/html/wordpress     # CentOS
chown -R www-data:www-data /var/www/html/wordpress # Ubuntu
chmod -R 755 /var/www/html/wordpress

🔐 创建数据库和用户(MySQL)

进入 MySQL:

mysql -u root -p

执行以下 SQL 命令:

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

🛠️ 配置 WordPress

浏览器访问:

http://你的服务器IP/wordpress

按照提示填写数据库信息:

  • 数据库名:wordpress
  • 用户名:wordpressuser
  • 密码:your_password
  • 数据库主机:localhost
  • 表前缀:默认 wp_

继续完成站点设置即可!


🎉 成功安装!

你现在就可以通过域名或 IP 地址访问你的 WordPress 博客了!


🧼 后续建议

  • 绑定域名,并申请 SSL 证书(可用 Let’s Encrypt)
  • 安装缓存插件(如 WP Super Cache)
  • 设置定期备份(推荐使用 UpdraftPlus)

如果你需要我帮你写一键安装脚本或者自动部署 WordPress 的方式(比如使用 Docker 或宝塔面板),也可以告诉我,我可以为你提供更简化的方式!

未经允许不得转载:秒懂云 » 京东云服务器如何安装WordPress?