WordPress is one of the world's most popular Content Management Systems (CMS), which is used for managing online blogs and websites. WordPress has witnessed incredible user adoption increases over the years and can be 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.
In this tutorial, we are going to set up a WordPress instance with an Apache web server on Alibaba Cloud with an ECS instance installed with Ubuntu, so that you can take advantage of all the amazing features that WordPress has to offer.
Before we can start, you will need to complete a couple of important steps to configure your server. Specifically, 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. For this, you can check out the How to Install LAMP Stack tutorial.
Let's now go through how you can deploy WordPress on Alibaba Cloud ECS.
Execute the following steps to launch an Alibaba Cloud ECS instance for your Linux machine:
1. Log in 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 Elastic Computing 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 based on your requirements. You can decide to opt for a Quick Launch or Custom Launch. 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. Note that different generation types offer different configuration and computing power. Next, you'll need to select Network Type, you can choose Classic Network or VPC, which ever best you're your requirements. 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 based on your requirements, and then select the desired storage type.
6. An option to set up 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 Create Instance to confirm and launch your server.
8. Your launched instances will appear in the Instances section
Let's discuss some related Alibaba Cloud Products. Alibaba Cloud ApsaraDB for RDS, installed with 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 a 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 still 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, to keep things simple, 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, and we do recommend that you choose a more secure password in a production environment. 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:
mysql> FLUSH PRIVILEGES;
Now, this part is done. Use "exit" to come out from the MySQL prompt as follows:
You should now be back to your regular command prompt.
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 http://wordpress.org/latest.tar.gz
This command downloads a compressed file containing the archived directory contents of the WordPress files to our home directory.
Now, 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, after 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.
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. So, 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
This file meets most of our needs already with some modifications to the parameters that hold our database information. Now, search the settings for
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.
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 the following:
root@iZt4n0drrwgfgq36vp3glgZ:~/wordpress # 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, after this, go to the document root to make a few final changes to the permissions.
root@iZt4n0drrwgfgq36vp3glgZ:~/wordpress # cd /var /www/html
Now, change the ownership of the files for increased security. We want to give user ownership to a 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 alternatively create an additional user for this purpose.
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, so 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
One Alibaba Cloud product related to the work we are doing in this tutorial is Alibaba Cloud DNS. It's worth checking out. 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, which will be at
http://server_domain_name_or_IP. On the WordPress initial configuration page, create an initial administrator account:
Enter the required information and the administrative account you wish to create. But, note that the user must note down his or 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 with this, 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 ECS instance installed with Ubuntu 14.04.
Some related Alibaba Cloud products are Alibaba Cloud Web Application Firewall (WAF) and CloudMonitor. With these products, we can add certain additional layers to increase the reliability and security of our website in the production environment. Additionally, you can also make a backup by taking snapshots of your running database to eliminate database failure. This is a feature of Alibaba Cloud ECS.
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 also filters out large number of malicious access attempts and alleviates the performance impact of HTTP/HTTPS flood attacks on servers.
Alibaba Cloud 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.
Alibaba Clouder - November 29, 2017
Alibaba Clouder - July 2, 2019
Alibaba Clouder - February 21, 2020
Alibaba Clouder - April 26, 2019
Alibaba Cloud Serverless - August 21, 2019
Alibaba Clouder - May 6, 2019
An on-demand database hosting service for MySQL, SQL Server and PostgreSQL with automated monitoring, backup and disaster recovery capabilitiesLearn More
An online computing service that offers elastic and secure virtual cloud servers to cater all your cloud hosting needs.Learn More
A virtual private cloud service that provides an isolated cloud network to operate resources in a secure environment.Learn More
More Posts by Alibaba Clouder