View here to log in or access your console


How to Deploy a WordPress Instance on Alibaba Cloud

This blog explains how to setup a WordPress instance with an Apache web server on Alibaba Cloud ECS Ubuntu 14.04.

About WordPress
WordPress is one of the world's most popular Content Management Systems (CMS) to manage online blogs and websites. WordPress has witnessed incredible user adoption over the years and is a great choice for getting a website up and running quickly. WordPress allows you to build a website on top of a MySQL backend with PHP processing.

Getting Ready
Before we can start, you will need to complete a couple of important steps to configure your server. You will need to first create a non-root user with sudo privileges here, and have a LAMP (Linux, Apache, MySQL and PHP) stack installed on your Alibaba Cloud ECS instance.

Deploying WordPress
Let's now go through step-by-step how to deploy WordPress on Alibaba Cloud ECS.

Step 1: Launch a Linux instance with ECS

Execute the following steps to launch an Alibaba Cloud ECS instance for your Linux machine:

  1. Login to your account through the Alibaba Cloud Management Console ( ( After logging in you will be redirected to the following dashboard.

2. Navigate to ‘Elastic Compute Service’ under the ‘Products & Services’ section. You will be redirected to the ECS overview dashboard. Click on ‘Instances’ in the sidebar menu to navigate to the Instances dashboard.

3. After creating an instance, choose your preferred payment method as per your requirements. You can decide to opt for a Starter Package or Advanced Purchase. Choose the Datacenter Region and Availability Zone to launch your ECS instance. If you specify the Region but do not specify the Availability Zone, then the instance will be placed in the default zone.

4. Under ‘Choose Instance Type’ select the Generation. Different Generation types offer different configuration and computing power. Select Network Type between Classic Network or VPC depending on your needs. Next, select Network Billing Type.

5. Choose Ubuntu or another Linux server image to launch the Linux server. Also, select the version of the image using the dropdown tab as per your requirements and then select the desired storage type.

6. An option to setup your server security by setting a password will be given. You may choose to set the password or set it later from the Management Console.

7. Check the overview of your purchase configuration and click Activate to confirm and launch your server.

8. Your launched instances will appear in the Instances section

That's how you can easily launch an ECS instance with Linux Operating System using the Management Console.

Step 2: Create a MySQL Database and User for WordPress

Related Alibaba Cloud Products: Alibaba Cloud ApsaraDB for RDS WordPress makes use of a relational database to store and manage sites and user data. We will use MySQL here in the blog, but for production environment, we can use Alibaba Cloud ApsaraDB for RDS, which is an on-demand database service that frees you from the administrative labor of database management and leaves you with more time to focus on your core business. ApsaraDB for RDS is a ready-to-use service offered on MySQL, SQL Server, and PostgreSQL. RDS handles routine database tasks such as provisioning, patch up, backup, recovery, failure detection and repair.

We have MySQL installed, but we need to create a database and user for WordPress.
To get started, log into the MySQL root account using this command:

Welcome to aliyun Elastic Compute Service! 
root@iZt4n0drrwgfgq36vp3glgZ:~# mysql - u root -p

Here, you need to enter the password of your MySQL root account that you had set at the time of software installation. Upon entering the password, you will be given a MySQL shell.

Let’s also create a separate database for WordPress. You can name it whatever you like, but here we will call it “wordpress”. Use the following command:

mysql> CREATE DATABASE wordpress; 

Note: Every MySQL statement should end in a semicolon (;). Make sure this is not the cause for any errors.

Now, for operating on our new database, we need to create an exclusive MySQL user account. Creating one-function databases and accounts is advisable from management and security standpoints.

Let’s call the new account “wordpress user” and assign “password” for the password field. The values for your user and password fields should be chosen wisely. Now create a user via this command:

mysql> CREATE USER wordpressuser@localhost  IDENTIFIED BY ‘password’ ;  
Query OK, 0 rows affected (0.00 sec)

Now we have a database and a user account specifically for WordPress. However, the user does not have access to the database yet. To grant database access to the user account, enter the following command:

mysql> GRANT ALL PRIVILEGES ON wordpress.  TO wordpressuser@localhost; 

This command grants database access to the user account. Now, to flush the privileges so that the current MySQL instance is aware of the recent privilege changes that we have made, we have to enter the following command:


Now, this part is done. Use “exit” to come out from the MySQL prompt as follows:

mysql> exit

You should now be back to your regular command prompt.

Step 3: Download WordPress

Next, download the actual WordPress files from the project's website.

Fortunately, WordPress always links the recent most stable version of their software to the same URL. Get the latest version of WordPress by using the following command:

root@iZt4n0drrwgfgq36vp3glgZ:~# wget 

This downloads a compressed file containing the archived directory contents of the WordPress files to our home directory.

Use the following command to extract the files required for rebuilding the WordPress directory:

root@iZt4n0drrwgfgq36vp3glgZ:~# tar xzvf latest.tar.gz

This command creates a directory called “wordpress” in your home directory.

Now, post executing these commands we will download a few more required packages. You can get these directly from Ubuntu's default repositories after you update your local package index:

root@iZt4n0drrwgfgq36vp3glgZ:~# sudo apt-get update
root@iZt4n0drrwgfgq36vp3glgZ:~# sudo apt-get install php5-gd libssh2-php

This facilitates working with images and also allows you to install plugins and update portions of your site using your SSH login credentials.

Step 4: Configure WordPress

We will do most of the configuration through a web Interface later on. However, we do need to do some work from the command line before we can get this up and running.

Let’s start by moving into the WordPress directory that we just unpacked, using the following command:

root@iZt4n0drrwgfgq36vp3glgZ:~# cd ~/wordpress

By default, a sample configuration file that closely matches the configuration we need is included. However, in order for WordPress to recognize the file, we need to copy it to the default configuration file location. To do so, use the following command:

root@iZt4n0drrwgfgq36vp3glgZ:~/wordpress# cp wp-config-sample.php wp-config.php

Now that we have a configuration file to work with, let's open it in a text editor:

root@iZt4n0drrwgfgq36vp3glgZ:~/wordpress# vi wp-config.php

As mentioned earlier, this file meets most of our needs already with some modifications to the parameters that hold our database information.

Search the settings for DB_NAME, DB_USER, and DB_PASSWORD for WordPress to correctly connect to and authenticate the created database. We need to populate these parameters with the information for the database created. It would be visible as shown below:

Change only the highlighted values, save and close the file once you finish.

Step 5: Copy Files to the Document Root

After we have configured our application, we must then copy it to Apache's document root where it can be served to our website’s visitors.
File transfer between directories using the rsync command can be done in an easy and reliable manner. This preserves permissions and offers data integrity features as well.
The document root location is /var/www/html/. We can transfer the WordPress files there by typing:

# sudo rsync -avP ~/wordpress/ /var/www/html/

This copies all of the contents from the directory you unpacked to the document root in a safe manner.
Next, go to the document root to make a few final changes to the permissions.

# cd /var /www/html

Change the ownership of files for increased security. We want to give user ownership to regular, non-root user (with sudo privileges) that you plan to use for interacting with your site. This could be a regular user, or we can create an additional user.

Next perform all the actions from the root account. Assign correct ownership on your uploads directory so that the owner can upload all kinds of content to your site. Currently, the permissions are too restrictive. Let us first create the uploads directory manually under wp-content directory at our document root, making it the parent directory for our content:

root@iZt4n0drrwgfgq36vp3glgZ:/ var /www/html
# mkdir /var/www/html/wp-content/uploads

Step 6: Complete Installation through the Web Interface

Related Alibaba Cloud Products: Alibaba Cloud DNS
Now that you have configured the software and your files are in place, complete the installation through the web interface.
In your web browser, go to your server’s domain name or public IP address:
On the WordPress initial configuration page, create an initial administrator account:

Fill out the required information and the administrative account you wish to create. (Note: The user must note down his/her password to login again, as the reset option will not work at this stage as the email ID has yet to be configured.)
Once finished, click on the install button at the bottom.

Once you fill in your account information you will be directed to the WordPress interface:

Your WordPress instance is now up and running on your ABC ECS (Ubuntu 14.04).

Final Step (Optional)

Related Alibaba Cloud Products: Alibaba Cloud WAF, Alibaba CloudMonitor

We can add certain additional layers to increase the reliability and security of our website in the production environment:

We can also make a backup by taking snapshots of our running database to eliminate database failure.

Alibaba Cloud WAF can be used to provide protection against web-based attacks, including SQL injections, XSS, Malicious BOT, command execution vulnerabilities, and other common web attacks. WAF filters out large number of malicious access attempts and alleviates the performance impact of HTTP/HTTPS flood attacks on servers.

Alibaba CloudMonitor can be used to provide in-depth insights into your cloud deployments. CloudMonitor provides advanced analytics on critical metrics such as CPU utilization, latency and also lets you customize metrics specific to business requirements.

Related Alibaba Cloud Products


Alibaba CloudMonitor

Web Application Firewall (WAF)

Alibaba Cloud DNS

ApsaraDB for RDS