WordPress is a blog-publishing system written in PHP. You can use WordPress to build your own websites on servers supporting PHP and MySQL databases or use WordPress as a content management system (CMS). This topic describes how to build a WordPress website on an ECS instance that is running the Linux operating system.


  • You must have registered an Alibaba Cloud account. If not, create a new Alibaba Cloud account first.
  • A security group of the VPC type is created. Inbound rules are added for the security group to allow traffic from port 80. If you want to remotely connect to the Linux instance by using SSH, traffic from port 22 is allowed. For more information about how to add security group rules, see Add security group rules.
  • A Linux ECS instance is created and deployed with the LNMP environment. For more information, see Manually build an LNMP environment in CentOS 7. This tutorial uses the following software versions:
    • Operating system: public image running CentOS 7.2 64-bit
    • NGINX: 1.16.1
    • MySQL: 5.7.29
    • PHP: 7.0.33
    • WordPress: 5.0.4
Note If you use software versions different from the preceding versions, you may need to adjust parameter settings based on your needs.

Background information

The tutorial is intended for enterprises or individuals who are familiar with Linux, but new to building WordPress websites on Alibaba Cloud ECS instances. You can also use the WordPress image provided in Alibaba Cloud Marketplace to quickly build a WordPress website.

Build a WordPress website

  1. Use the ECS console to remotely connect to the ECS instance that is deployed with the LNMP environment and configure a database for the WordPress website.
    1. Remotely connect to the ECS instance.
    2. Log on to the MySQL database.
      mysql -uroot -p
    3. Create a database for the WordPress website that you want to build.

      In this tutorial, the database created for the WordPress website is wordpress.

      create database wordpress;
    4. Create a user.

      In this tutorial, the name of the created user is user and the password is password123.

      create user 'user'@'localhost' identified by 'password123';
    5. Grant the user all permissions on the wordpress database.
      grant all privileges on wordpress.* to 'user'@'localhost' identified by 'password123';
    6. Make the configuration take effect.
      flush privileges;
    7. Exit MySQL.
  2. Download WordPress.
    Note If you download WordPress on an ECS instance located in mainland China, an error 429 Too Many Requests will be reported. We recommend that you try multiple times or download the WordPress installation package from a third-party website.
    1. Go to the /usr/share/nginx/html/ directory.
      cd /usr/share/nginx/html
    2. Download WordPress.
      wget https://cn.wordpress.org/wordpress-<Version information>.tar.gz

      The version used in this tutorial is 5.0.4.

    3. Decompress the WordPress installation package.
  3. Modify the WordPress configuration file.
    1. Copy the content of the wp-config-sample.php file in the WordPress installation directory to wp-config.php and save wp-config-sample.php as a copy.
      cd /usr/share/nginx/html/wordpress
      cp wp-config-sample.php wp-config.php
    2. Edit the wp-config.php file.
      vim wp-config.php
    3. Press i to switch to the edit mode and modify MySQL-related configurations based on the wordpress database. An example of the modification code is as follows:
      // ** MySQL settings - The information is based on the host in use. ** //
      /** WordPress database name */
      define('DB_NAME', 'wordpress');
      /** MySQL database username */
      define('DB_USER', 'user');
      /** MySQL database password */
      define('DB_PASSWORD', 'password123');
      /** MySQL host */
      define('DB_HOST', 'localhost');
    4. After the modification is complete, press Esc, type :wq, and press Enter to save and close the configuration file.
  4. Install WordPress and log on to the WordPress website.
    1. Enter http://Publich IP address of the ECS instance/wordpress in the browser of your computer to enter the WordPress installation page.
    2. Enter basic information of the WordPress website and click Run the installation.
      The parameters are described as follows:
      • Site Title: The name of the WordPress website. Example: demowp.
      • Username: The username used to log on to WordPress. Keep your username secure. Example: testwp.
      • Password: We recommend that you choose a secure password. Example: Wp.123456.
      • Your Email: The email used to receive notifications. Example: 1234567890@aliyun.com.
    3. Click Install Wordpress.
    4. Enter the username testwp and password Wp.123456 that are used to install WordPress and click LOGIN.
      You have logged on to your WordPress website.

Resolve the domain name of the WordPress website

Accessing your WordPress website by using the public IP address of the ECS instance compromises the security of the ECS instance. If you have a domain name or want to register a domain name for the WordPress website, follow these steps. The domain name to register in this tutorial is www.WordPress.EcsQuickStart.com.

  1. Register the domain name.
    For more information, see Register a domain name.
  2. Apply for an ICP filing.
    If the website your domain name points to is hosted on an ECS instance located in mainland China, you must apply for an ICP filing. see Apply for an ICP filing.
  3. Resolve the domain name and bind it to the public IP address of the ECS instance.

    Domain name resolution is necessary for you to access your website by using a domain name. For more information, see Domain name resolution.

  4. Return to the ECS console, remotely connect to the ECS instance on which the WordPress website is deployed, and log on to the MySQL database.
    mysql -uroot -p
  5. Use the wordpress database.
    use wordpress;
  6. Replace the public IP address of the ECS instance with the new domain name.
    update wp_options set option_value = replace(option_value, 'http://Public IP address of ECS instance/wordpress', 'http://www.WordPress.EcsQuickStart.com/wordpress') where option_name = 'home' OR option_name = 'siteurl';
  7. Exit MySQL.

    The new domain name is configured for your WordPress website.