All Products
Search
Document Center

Elastic Compute Service:Manually build a WordPress website (Linux)

Last Updated:Dec 24, 2025

To gain full control over your website environment, you can manually deploy an LNMP stack and install WordPress. This lets you flexibly build blogs and portal websites.

Preparations

  • Enable public access: Assign a static public IP address to the instance or associate an elastic IP address (EIP) with the instance.

  • Add a security group rule: In the inbound direction for the security group of the instance, allow TCP access on ports 22 and 80.

Procedure

This topic uses Alibaba Cloud Linux 3 and WordPress 6.4.4 as an example.

Step 1: Deploy an LNMP environment

  1. Log on to the ECS instance.

    1. Go to ECS console - Instances. In the top navigation bar, select the target region and resource group.

    2. Go to the details page of the target instance. Click Connect and select Workbench. Follow the prompts on the page to log on to the terminal.

  2. Deploy an LNMP stack.

    Install core components such as Nginx, MySQL, and PHP.

    WordPress depends on specific versions of PHP and MySQL. A version mismatch will cause the WordPress installation to fail. For more information about dependencies, see WordPress Compatibility.

Step 2: Create a WordPress database

Create a dedicated database and database user for WordPress.

  1. Log on to MySQL. Use the database password that you set when you deployed the LNMP environment.

    mysql -u root -p
  2. Create a database and a user, and then grant permissions.

    Record the database name, username, and password for later use.

    -- Create a database named WORDPRESS_DATABASE
    CREATE DATABASE WORDPRESS_DATABASE;
    
    -- Create a dedicated user WORDPRESS_USER and set a password. We recommend that you set a strong password that is at least 12 characters long and contains uppercase letters, lowercase letters, digits, and special characters.
    CREATE USER '<span class="var-span" contenteditable="true" data-var="WORDPRESS_USER">WORDPRESS_USER'</span>@'localhost' IDENTIFIED BY '<span class="var-span" contenteditable="true" data-var="WORDPRESS_PASSWORD">WORDPRESS_PASSWORD'</span>;
    
    -- Grant this user all privileges on the wordpress database
    GRANT ALL PRIVILEGES ON wordpress.* TO '<span class="var-span" contenteditable="true" data-var="WORDPRESS_USER">WORDPRESS_USER'</span>@'localhost';
    
    -- Flush privileges to apply the settings
    FLUSH PRIVILEGES;
    
    -- Exit MySQL
    EXIT;
    By default, the password validation plugin is installed in MySQL 5.7 and later. The password must be 8 to 30 characters long and contain uppercase letters, lowercase letters, digits, and special characters. Supported special characters include ()` ~!@#$%^&*-+=|{}[]:;‘<>,.?/.

Step 3: Download and configure WordPress

  1. Go to the Nginx website root directory and download the Chinese version of WordPress 6.4.4.

    To install the English version of WordPress, replace the URL with https://wordpress.org/wordpress-6.4.4.zip. In the subsequent steps, you must also replace the compressed package name with wordpress-6.4.4.zip.
    sudo cd /usr/share/nginx/html
    sudo wget https://cn.wordpress.org/wordpress-6.4.4-zh_CN.zip
  2. Install the unzip command and decompress the WordPress package.

    sudo yum install unzip -y
    sudo unzip wordpress-6.4.4-zh_CN.zip
  3. Copy the wp-config-sample.php file to wp-config.php and keep the original file as a backup.

    cd /usr/share/nginx/html/wordpress
    sudo cp wp-config-sample.php wp-config.php
  4. Edit the configuration file. Enter the database information that you created in Step 2, including the database name, username, and password.

    sudo vim wp-config.php

    Press the i key to enter edit mode.

    /** The name of the database for WordPress */
    define('DB_NAME', '<span class="var-span" contenteditable="true" data-var="WORDPRESS_DATABASE">WORDPRESS_DATABASE'</span>);
    
    /** MySQL database username */
    define('DB_USER', '<span class="var-span" contenteditable="true" data-var="WORDPRESS_USER">WORDPRESS_USER'</span>);
    
    /** MySQL database password */
    define('DB_PASSWORD', '<span class="var-span" contenteditable="true" data-var="WORDPRESS_PASSWORD">WORDPRESS_PASSWORD'</span>);
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');

    After you make the changes, press the Esc key, enter :wq, and press the Enter key to save the file and exit.

Step 4: Configure Nginx

Modify the default site configuration of Nginx to correctly handle PHP requests.

  1. Back up the default configuration and create a new Nginx configuration file.

    sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
    sudo vim /etc/nginx/conf.d/default.conf
  2. Modify the Nginx configuration file.

    Press the i key to enter edit mode. In the server and location ~ .php$ blocks, replace the content after root with the WordPress root directory. In this example, the WordPress root directory is /usr/share/nginx/html/wordpress.

    image

    Press the Esc key, enter :wq, and then press the Enter key to save and exit the configuration file.

  3. Check the configuration syntax.

    If syntax is ok is displayed, you can restart Nginx.

    sudo nginx -t
    If a syntax error is reported, you can run sudo mv /etc/nginx/conf.d/default.conf.bak /etc/nginx/conf.d/default.conf to restore the default configuration.
  4. Restart Nginx to apply the configuration.

    sudo systemctl restart nginx

Step 5: Install and log on to the WordPress website

After you complete the server-side configuration, you must use a browser to initialize WordPress.

  1. On your local machine, open a browser and go to http://<Public IP address of the ECS instance> to access the WordPress installation page.

  2. Enter the basic information for the website, including Site Title, administrator Username, Password, and Your Email. Then, click Install WordPress.

  3. After the installation is complete, click Log In. Use the username and password that you set in the previous step to log on.

    A successful logon indicates that the WordPress website is built and running. For more information, see the official WordPress documentation.

What to do next

Manage files using FTP

To upload WordPress themes or plugins using FTP, you must build an FTP site on a Linux instance.

Resolve a domain name and configure HTTPS

Accessing your website using its IP address is unprofessional and insecure. We recommend that you associate a domain name with your website and enable HTTPS encryption.

  1. Register a domain name and apply for an ICP filing

    • If you do not have a domain name, you can register a domain name on Alibaba Cloud.

    • If your website is hosted on an Alibaba Cloud server in the Chinese mainland, you must apply for an ICP filing for the domain name.For more information, see ICP filing process.

  2. Set up domain name resolution

    Resolve the domain name to the public IP address of the ECS instance.

  3. Replace the public IP address of the instance with the new domain name.

    1. Remotely connect to the instance and log on to the MySQL database.

      mysql -u root -p
    2. Switch to the WordPress database and set the domain name.

      Replace public_ip with the public IP address of the instance and domain with your domain name.

      USE wordpress;
      UPDATE wp_options SET option_value = replace(option_value, 'http://PUBLIC_IP', 'http://DOMAIN') WHERE option_name = 'home' OR option_name = 'siteurl';
      EXIT;
  4. Configure an SSL certificate (HTTPS) 

    Deploying an SSL certificate enables HTTPS-encrypted data transfer for your website. This protects user privacy and improves browser trust and search engine optimization (SEO) rankings.

FAQ

Why can't I access WordPress using the public IP address?

  • Check security groups: Confirm that port 80 is allowed in the security group of the instance.

  • Check the firewall: Confirm that the internal firewall of the operating system, such as firewalld, is not blocking port 80.

  • Check service status: On the ECS instance, run sudo systemctl status nginx and sudo systemctl status php-fpm to make sure the services are in the active (running) state.

  • Check port listening: Confirm that port 80 is being listened on.

For more information about how to troubleshoot the issue, see What do I do if I cannot access a service deployed on an instance?.

Why are pages inaccessible after I set permalinks in WordPress?

Making your website static helps search engines index it. Before you set permalinks for your WordPress site, you must first set static rules in the Nginx server.

  1. Remotely connect to the instance and open the Nginx configuration file.

    sudo vim /etc/nginx/conf.d/default.conf

    Press the i key to enter edit mode. In the location / block, add the following code.

    try_files $uri $uri/ /index.php?$args;

    Press the Esc key, enter :wq, and then press the Enter key to save and exit the configuration file.

  2. Restart the Nginx service to apply the configuration.

    sudo systemctl restart nginx

Why am I prompted for FTP logon credentials or told that a directory cannot be created when I update WordPress or upload themes or plugins?

This issue may occur because the permissions for the WordPress configuration file, themes, or plugins are insufficient. You can follow these steps to resolve the issue.

  1. Log on to the ECS instance and open the WordPress configuration file.

    sudo vim /usr/share/nginx/html/wordpress/wp-config.php

    Press the i key to enter edit mode. At the bottom of the file, add the following code.

    define("FS_METHOD","direct");
    define("FS_CHMOD_DIR", 0777);
    define("FS_CHMOD_FILE", 0777);

    Press the Esc key, enter :wq, and then press the Enter key to save and exit the configuration file.

  2. Return to the WordPress dashboard and refresh the page. This should resolve the issue of being prompted for FTP logon credentials.

    If the issue of being unable to create a directory persists, change the user who has permissions on the website root directory to the Nginx user nginx.

    sudo chown -R nginx /usr/share/nginx/html/wordpress

How do I change the default username and password of the MySQL 5.7 database in a WordPress image?

  1. Remotely connect to the ECS instance and log on to the MySQL database.

    mysql -u root -p
  2. Go to the mysql database and view the username.

    use mysql;
    select user from mysql.user;
  3. Change the username and password of the database.

    • Change the database username to a new username.

      UPDATE user SET user='NEW_USER_NAME' WHERE user='USER_NAME';

      For example, to change the username from root to admin:

      UPDATE mysql.user SET user='admin' WHERE user='root';
    • Change the password of the database user.

      ALTER USER 'USER_NAME'@'localhost' IDENTIFIED BY 'PASSWORD';

      For example, to change the password of the root user to Password@2025!:

      ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password@2025!';
  4. Flush the privileges to apply the changes and then exit the MySQL database.

    FLUSH PRIVILEGES; 
    EXIT;

References