How I Built My Personal Website with Alibaba Cloud

By Partha Sarathy, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

In today’s post, I’m going to show you how I deployed my website, sarathy.tech, on Alibaba Cloud.

I built my website using WordPress on Alibaba Cloud Elastic Compute Service (ECS) instance with Nginx, PHP 7.2, FastCGI, MariaDB, and Redis caching for maximum performance.

Before you get started, I’m assuming that you already have a basic understanding of the cloud, networking, and knowledge of Linux command line.

You also need a functional domain name for your website.

Step #1: Create a New Account

If you don’t have an account already, you can sign up here. New users can enjoy $300-$1200 worth in free trial, valid for 2 months. If you are not sure how to do this, refer to this tutorial.

After setting up an account, you’re ready to deploy a high performance WordPress website!

Step #2: Create a New ECS Instance

Log In into Alibaba Cloud Console by entering your Email and Password. You may need to enter a security code for security purposes.

In the Alibaba Cloud Console, click Products and select Elastic Compute Service from the list.

Click Instances, and choose your Region from top left drop-down menu. A list of available regions will be displayed.

Click Create Instance. For my instance, I have selected the following configurations.

  • Billing method: Subscription
  • Instance Type: IO Optimized
  • vCPU: 1
  • RAM: 4GB
  • Family: Balanced Type mn4
  • Quantity: 1 Units

I have selected an IO Optimized instance with 4GB of physical memory (RAM) and 1 virtual CPU. If your website will be hosting more dynamic content, consider purchasing a higher-spec instance.

Now you have to select an appropriate Image for your instance. I have chosen an Ubuntu 16.04 image for my server.

  • Image Type: Public Image
  • Operating System (OS): Ubuntu
  • OS Version: 16.04 64bit
  • Enable Security Enhancements. This feature will add some security features like backdoor detection, remote login alerts, etc.

There are a few other configurations to consider, I have chosen the default settings for the rest.

Step #3: Setup Alibaba Cloud DNS

Alibaba Cloud DNS is an authoritative highly available and highly scalable domain name resolution and management service. DNS stands for Domain Name System, which helps us to map our IP address to a domain name. To use Alibaba Cloud’s DNS service, you need to update the nameservers in your Domain’s control panel. The name servers will be provided by Alibaba Cloud.

Before you start, you need to get the public IP of our Instance. Follow the steps below to proceed:

  • Log In to ECS Management Console
  • Click Instances
  • Note down the public IP of the instance
  • Log In to Alibaba Cloud Console
  • Click CloudDNS from the Products list
  • Click BasicDNS
  • Click Add Domain Name
  • Enter your Domain name and click Confirm

A couple of Name Servers will be displayed. Update them in your Domain’s control panel. DNS migration may take up to 48 hours, so you’ll have to be patient!

Now, you have to add two “A” records.

Enter the following details for the first “A” record.

  • Record Type: A
  • Host: @
  • ISP Line: Default
  • Value: Your instance’s IP address
  • TTL: 10 minutes

Enter the following details for the other “A” record.

  • Record Type: A
  • Host: *
  • ISP Line: Default
  • Value: Your instance’s IP address
  • TTL: 10 minutes

Step #4: Connecting to Our Instance

You can connect to your instance via VNC or SSH. VNC requires high-speed internet connection whereas SSH works fine even in slow connections. So, I prefer using SSH over VNC.

Connecting through Linux / Mac
Open your command line and enter the following code:

Type yes and enter the root password. If the password is correct, you’ll successfully logged in.

Connecting through Windows
If you’re using Windows machine, you’ll need to use a third party program such as PuTTY. Connect to the server using PuTTY. Enter your instance’s username and password to log in

Step #5: Checking for Driver Errors

When you boot your instance for the first time, it’s a good practice to check for driver-related error messages and warnings. In Linux, the dmesg command is used for viewing driver messages.

The Intel RAPL driver displayed an error message. If you face the same problem, you can safely blacklist the driver by running the following command.

The kernel won’t load this driver during next boot. Reboot the server by typing the reboot command.

Step #6: Update the System

Ubuntu is based on Debian. The APT package manager is used in all Debian based distros including Ubuntu.

This will update all packages and the kernel to the latest version. A reboot is recommended after a distribution upgrade.

Let’s clean up the system and remove all packages that are no longer required.

Step #7: Set the Default Time Zone

Run the following command:

Choose your geographic area and choose your city.

Step #8: Install Nginx

Nginx is a high-performance web server capable of handling thousands of concurrent connections. It’s a great alternative to the Apache web server.

Before installing, let’s install the required packages:

You’re going to install the latest version of Nginx, which is not available in the official Ubuntu repository.

Add Nginx repository:

Add Nginx’s signing key:

Update the package list:

Install NGINX:

Verify whether Nginx is successfully installed or not:

Remove the default configurations:

Remove the default webpage:

Start Nginx during boot:

Step #9: Install PHP-FPM

Add PHP 7.2 PPA:

Update the package list:

Install PHP:

Verify whether PHP is successfully installed or not:

Install required PHP extensions:

Start PHP during boot:

Step #10: Install MariaDB

Add MariaDB PPA:

Update the package list:

Install MariaDB server:

During the installation, you will be prompted to enter a root password. Re-enter the same password & hit Enter.

Note that the default installation is not secure. You can secure the installation by running the following command:

You’ll be asked to enter your root password. You will then be prompted with some questions. I have used the following settings (Press Y for Yes, N for No):

  • Change the root password? No
  • Remove anonymous users? Yes
  • Disallow root login remotely? Yes
  • Remove test database and access to it? Yes
  • Reload privilege tables now? Yes

Start MariaDB during boot:

Step #11: Create a Database & a DB user

Login as root:

Enter your root password. You’ll be logged in to MariaDB console.

Create a new user:

Replace “example-user” and “ password” with you own username and password.

Create a new database:

Grant all permissions to newly created user:

Reload the privilege table:

Exit the console:

Step #12: Configure Nginx

Open Nginx configuration file:

Don’t forget to replace example.com with your actual domain name.

Paste the following:

This is our global Nginx configuration. To exit nano, press Ctrl+O then hit Enter.

You have to create another one for your domain:

Paste the following:

Test Nginx configuration:

If the test is successful, restart nginx by typing:

Step #13: Configure Redis Server for Object Caching

Install Redis server:

Start Redis server during boot:

Configure Redis server’s memory limit:

Restart Redis server:

Restart PHP:

Step #14: Configure PHP

Open PHP 7.2 configuration file:

Change the following values:

Step #15: Install FREE SSL Certificate By Let’s Encrypt

Add Let’s Encrypt PPA:

Update the package list :

Install certbot for Nginx:

Obtain SSL:

Press 2 & hit Enter.

You’ll obtain your SSL certificate & certbot will automatically configure it for you.

Keep in mind that the SSL certificate will expire in 90 days. Run the following command to manually renew the certificate:

Step #16: Install WordPress

Move to Nginx root directory:

Download WordPress:

Unzip the package

Move all files to the Nginx’s root directory:

Create a directory for storing caches:

Change ownership of the Nginx’s root directory:

Now type the URL of your website in your browser’s address bar.

Complete the installation by following the instructions on the screen. You will need to enter the DB details from step 10.

Also, don’t forgot to install Nginx Cache and Redis Cache plugins.

Conclusion

I hope you enjoyed this guide. This is how I deployed my blog on Alibaba Cloud using WordPress and an Elastic Compute Service (ECS) instance. If you are experiencing any issues do let me know in the comments section!

Reference:

https://www.alibabacloud.com/blog/how-i-built-my-personal-website-with-alibaba-cloud_593842?spm=a2c41.11807748.0.0

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store