Help Center/ Relational Database Service/ Best Practices/ RDS for MySQL/ Using RDS for MySQL to Set Up WordPress
Updated on 2024-09-30 GMT+08:00

Using RDS for MySQL to Set Up WordPress

WordPress is a blog platform developed based on PHP. It is usually used with RDS for MySQL database servers to help users build websites. This section describes how to set up WordPress in the Linux, Apache, MySQL and PHP (LAMP) environment using Huawei Cloud VPC, ECS, and RDS for MySQL.

  1. Configuring Network Information
  2. Buying an ECS
  3. Setting Up the LAMP Environment
  4. Buying and Configuring an RDS DB Instance
  5. Installing WordPress

Preparations

During the setup, you will use the following services or tools:

  • Cloud services: Huawei Cloud ECS and RDS for MySQL.
  • MySQL client: a database configuration tool
  • PuTTY: a remote login tool

The previous software is provided by third-party websites. The information is just for your reference and not for commercial use.

Configuring Network Information

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Choose Networking > Virtual Private Cloud.
  4. On the displayed page, click Create VPC to create a VPC, such as vpc-01.
  5. On the displayed page, enter a VPC name, set IPv4 CIDR Block to 192.168, select an AZ as required, and add a subnet. Retain the default settings for other parameters. Then, click Create Now. After the VPC is created, return to the network console.
  6. On the network console, choose Access Control > Security Groups and click Create Security Group. The following uses sg-01 as an example.
  7. On the Security Groups page, locate the target security group and click Manage Rules in the Operation column.
  8. Click Add Rule and add an inbound rule for the EIP bound to the ECS.

Buying an ECS

  1. Log in to the management console.
  2. Click in the upper left corner and select a region and a project.
  3. Choose Compute > Elastic Cloud Server. The Elastic Cloud Server page is displayed.
  4. On the ECS console, buy an ECS.

    1. Configure basic settings: Select the pay-per-use billing mode, a region, and an image. Retain the default settings for other parameters.
      The public image CentOS7.4 64bit for P2v(40GB) is used as an example, as shown in Figure 1.
      Figure 1 Selecting an image
    2. Configure network: Select a VPC and security group, and purchase an EIP. Retain the default settings for other parameters.
      1. Select the created VPC vpc-01.
      2. Select the created security group sg-01.
      3. Select Auto assign for EIP.
    3. Configure advanced settings: Enter an ECS name and password, and click Next: Confirm.
      1. Enter an ECS name, such as ecs-01.
      2. Enter a password.
    4. Confirm: Confirm the information and click Next.

  5. After the ECS is created, view and manage it on the ECS console.

Setting Up the LAMP Environment

  1. Download the PuTTY client.
  2. Decompress the package, locate putty from the extracted files and double-click it.
  3. In the displayed PuTTY configuration dialog box, choose Session and specify basic options for your PuTTY session in the right pane. Then, click Open as shown in Figure 2.

    1. Enter the EIP of your ECS in the Host Name (or IP address) text box.
    2. Enter a session name in the Saved Sessions text box and click Save. Wordpress is used as an example. Retain the default settings for other parameters.
      Figure 2 Configuring PuTTY

  4. In the displayed login window, enter the ECS username and password to log in to ECS.
  5. Obtain the root permissions so that you can enter commands in PuTTY.

    Enter commands to install MySQL, PHP or other software. For example, run the following command to install PHP:

    yum install -y httpd php php-fpm php-server php-mysql mysql

    The installation is complete if the following command output is displayed:
    Complete

  6. Run the following command to install a decompression software:

    yum install -y unzip

  7. Run the following command to download and decompress the WordPress installation package:

    wget -c https://wordpress.org/wordpress-4.9.1.tar.gz

    tar xzf wordpress-4.9.1.tar.gz -C /var/www/html

    chmod -R 777 /var/www/html

  8. After the installation is complete, run the following commands to start related services in sequence:

    systemctl start httpd.service

    systemctl start php-fpm.service

  9. Enable automatic start of the service during system startup.

    systemctl enable httpd.service

Buying and Configuring an RDS DB Instance

  1. Buy a DB instance as required.

    • DB instance rds-01 is used as an example. Select MySQL 5.7.
    • Ensure that the RDS DB instance uses the same security group as the ECS so that you can access the RDS DB instance through the ECS.
    • Set the root user password and keep the password secure. The system cannot retrieve your password.

  2. Go to the RDS console. On the Instances page, click the target DB instance rds-01. The Overview page is displayed.
  3. Choose Databases in the navigation pane on the left and click Create Database. In the displayed dialog box, enter a database name, such as wordpress, select a character set, and authorize permissions for database users. Then, click OK.

    Figure 3 Creating a database

  4. Choose Accounts in the navigation pane on the left and click Create Account. In the displayed dialog box, enter the database username, such as tony, authorize permissions for database wordpress created in 3, enter the password and confirm the password. Then, click OK.

    Figure 4 Creating an account

Installing WordPress

  1. On the Elastic Cloud Server page, locate the target ECS and click Remote Login in the Operation column.
  2. In the Internet Explorer, enter http://EIP/wordpress in the address box and click Let's go!

    In the preceding URL, EIP indicates the EIP automatically assigned when you purchase the ECS in Buying an ECS.

    Figure 5 Visiting WordPress

  3. Enter database connection information and click Submit.

    • The database name is wordpress.
    • The username is tony.
    • The password is the one that you set for tony.
    • The database host is the floating IP address of DB instance rds-01.
    Figure 6 Entering database connection information

  4. After the database connection details are verified, click Run the installation.

    Figure 7 Running the installation

  5. Set Site Title, Username, and Password for logging in to your blog. Then, click Install WordPress.

    Figure 8 Setting basic information

  6. Click Log In after WordPress has been successfully installed.

    Figure 9 Successful installation

  7. Enter the username and password on the displayed login page. Then, click Log In.

    Figure 10 Logging in

  8. Check that WordPress has been deployed successfully.

    Figure 11 Verification