×
Community Blog Deploying a Ghost Blog on Alibaba Cloud

Deploying a Ghost Blog on Alibaba Cloud

In this article, MVP Partha Sarathy will be sharing his experience of deploying a Ghost blog platform on Alibaba Cloud for his personal website.

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 article, I'll be showing you how to deploy a Ghost blog like a pro on Alibaba Cloud's platform.

1

If you don't have an Alibaba Cloud account, you can create one by clicking here. If you are a new user, you can enjoy a free trial worth $300 - $1200.

What Is Ghost?

Ghost is an open-source publishing platform which can be used to create blogs, magazines and news websites. It is written in JavaScript. It uses Node.js to execute JavaScript code in the Server-side & MySQL for database operations.

Ghost vs. WordPress

2

Both Ghost and WordPress can be used for creating blogs. However, both platform has its own advantages and disadvantages. Let's compare them.

1. Performance

WordPress is written in PHP whereas Ghost is written in JavaScript. PHP is very slow compared to JavaScript. So blogs powered by Ghost will load a lot faster than WordPress.

Ghost also has built-in lossless image compression, code minification, etc. These features help us to improve our page performance

2. Ease of Use

Both Ghost and WordPress do not require any programming skills to create blogs.

But Ghost is very simple and easy to use compared to WordPress. It makes you a lot easier to start a blog on Ghost. WordPress has a lot of features that are only used by advanced users

3. Security

WordPress is the most vulnerable web application in the web because of its popularity. On the other hand, Ghost is new and less popular. It has many built-in security features that WordPress doesn't have.

For example, in Ghost, you need not to install anything to serve your blog in HTTPS. But WordPress requires you to install third-party plugins to achieve the same.

4. Search Engine Friendliness

Ghost has a built in functionality for SEO. But in WordPress, we have to install a 3rd party SEO plugin for optimizing our site for SEO. Additionally, Ghost blogs always load faster than WordPress. So Ghost blogs always rank higher in Search Engines.

5. Extendability

WordPress has a plugin ecosystem. WordPress has thousands of plugins available on the internet. So if you want to extend your website's functionality Ghost may not be the right choice for you

Deployment Process

3

Here is the architectural diagram of our deployment process. Our blog will be hosted on an Alibaba Cloud Elastic Compute Service (ECS) instance.

Ghost blogs also require a database server. We will use Alibaba Cloud's highly available managed MySQL database service, ApsaraDB for RDS MySQL.

Both the RDS instance and the ECS instance will be in the same Virtual Private Cloud (VPC). Only the ECS instance is exposed to the internet. Which means you can only access the RDS instance only from the ECS.

An Elastic IP will be attached to our ECS instance. We also register a domain name for our blog. The domain name will be associated with the Elastic IP Address (EIP) using Alibaba Cloud DNS service. If you can't understand the terms, don't worry. I will explain everything in detail

Step 1: Create a VPC

VPC stands for Virtual Private Cloud. Each VPC is logically isolated. Every VPC has its own Route Table, VSwitch, etc.

Let's create a VPC

  • Log In to Alibaba Cloud Console
  • Click on Products
  • Click Virtual Compute Cloud under Networking section

4

Regions are physical locations of Alibaba Cloud Data Centers. A region may have one or more Data Centers. They are called Availability Zones

  • Choose your Region from the upper left corner

5

  • Click on Create VPC

6

  • VPC Name: ghost -blog. The VPC name should be lower case

7

Leave other fields as default and head over to VSwitch section

  • VSwitch Name: ghost-blog-vswitch
  • Zone: Choose anyone from the dropdown box
  • Destination CIDR Block: 192.168.0.0/29

8

  • Click OK

The VPC will be created successfully. After the VPC creation is successful, the VPC details will be displayed as follows

9

Step 2: Create an ECS Instance

ECS stands for Elastic Compute Cloud, an Alibaba Cloud service that offers scalable virtual machines on the cloud. ECS instances are resizable and both horizontally and vertically scalable.

Let's say, our blog has daily 100 visitors and our current ECS instance is capable of handling the load. What will you do if our daily visitors are increased from 100 to 200?

We have to upgrade our ECS instance, right?

Well, Now we have two options, We can either increase the capacity of ECS our instance or increase the number of ECS instances and distribute the traffic via Elastic Load Balancer ( or ELB). Increasing the size of an instance is called Vertical Scaling and increasing the numbers of the instances is called Horizontal Scaling.

If our daily visitors decreases from 200 to 100, we can release the resources that are no longer needed. So, we pay only for what we actually use.

Let's create an ECS instance

  • Log In to Alibaba Cloud Console
  • Click on Products
  • Click Elastic Compute Cloud under Elastic Computing section

10

  • Click on Instances

11

  • Choose your Region from the upper left corner

12

  • Click Create Instance

13

  • Billing Method: Subscription
  • Region: Random
  • vCPU: 1 vCPU
  • Memory: 1 GiB

14

  • Instance Type: ecs.t5-lc1m1.small

15

Now, we have to select an Operating System for our ECS instance. We will use Ubuntu 18.04 LTS. Ubuntu is one of the most popular Linux distributions in the world. It is based on Debian.

  • Image Type: Public Image
  • Operating System: Ubuntu
  • Operating System Version: 18.04 64bit
  • Enable Security Enhancements. This will add additional security features like Backdoor detection to our ECS instance

16

Now we have to add storage to our instance. To reduce costs, I've chosen Ultra Cloud Disk. If you want more performance, go for SSD Cloud Disk.

  • Disk Type: Ultra Disk
  • Disk Capacity: 20 GiB

17

Go to the next page by clicking Next: Networking at the bottom right corner of the page.

  • For VPC, select the VPC we created in Step 1 from the drop-down menu

18

We need a public IP address to reach our ECS instance over the internet

  • Check Assign Public IP
  • BandwidthPricing: Pay By Traffic
  • Data Transfer Rate: 200 Mbps

19

Security Groups are used to set firewall rules. We'll use the default security group.

  • Enable both port 80 and 443. Port 80 is used for HTTP and port 443 is used for HTTPS

20

Go to the next page by clicking Next: System Configuration at the bottom right corner of the page.

We have to choose an authentication method to access our instance. We can use either SSH key pair or password-based authentication. For simplicity, I'm going with password-based authentication although it is less secure compared with SSH Key-pair based authentication.

  • Authentication Method: Password
  • Enter a STRONG PASSWORD in both Password and Confirm Password Fields.

21

  • Instance Name: ghost-blog
  • Host: Enter your domain name

22

Now we are ready to create and launch our ECS instance. Click the Preview button at the bottom right of the page. Review the details and complete the purchase.

After we complete the purchase, the ECS instances will be created. Note down the public IP address of the ECS instance.

23

Step 3: Register a Domain Name

When we deploy an ECS instance, we'll get an IP address to access it. However, it is not easy for our end users to remember our IP address. Instead, we have to register a domain name for our blog.

At the time of writing this article, Alibaba Cloud is offering a free .TECH to new users. If you're an old user, you can get a .XYZ domain for only 0.18$ for the first year.

Let's register a domain name

  • Log In to Alibaba Cloud Console
  • Click on Domains

24

  • Click Purchase

25

You will be redirected to a page similar to the following image where you can buy a domain for our blog.

  • Enter a Domain that you want to register in the Search bar & click Find Domain button.

26

The search results will be displayed. Choose your desired domain from the list & click Add To Cart

27

  • Click Buy Now & then complete the purchase

28

Step 4: Setup Alibaba Cloud DNS

  • Log In to Alibaba Cloud Console
  • Click Products
  • Choose Alibaba Cloud DNS as shown in the following figure

29

  • Click on the domain we registered in Step 4.

30

  • Click Add Record

31

  • Record Type: A
  • Host: blog.example.com (Replace example.com with your domain name)
  • Value: ECS instance IP
  • Leave other options as default
  • Finally, Click OK to create the DNS record

32

Your DNS record should look similar to the below picture.

33

Step 5: Create an ApsaraDB for RDS instance

ApsaraDB for RDS is a managed Relational Database service being offered by Alibaba Cloud.

Let's create an RDS instance for our blog.

  • Log In to Alibaba Cloud Console
  • Click on Products
  • Click ApsaraDB for RDS under ApsaraDB section.

34

  • Choose your Region from the upper left corner

35

  • Click Create Instance

36

  • Choose Subscription tab
  • Region: The same region we previously used for creating our VPC and ECS instance
  • DB Engine: MySQL
  • Version: 5.7
  • Edition: High Availability

37

  • Network Type: VPC
  • Then select the VPXC and VSwitch we created in Step 1
  • Instance Type: 1 Core, I GiB
  • Storage Capacity: 5 GiB
  • Purchase Duration: 1 Month (or higher)
  • Tick the Auto Renew box
  • Quantity: 1

38

Review the details. If everything is OK, proceed

to buy by clicking the Buy Now button

39

Step 6: Configuring RDS

  • Log In to Alibaba Cloud Console
  • Click on Products
  • Click Apsara for RDS under ApsaraDB section.

40

  • Click on the RDS instance we created in Step 5

41

Now we are going to whitelist our VPC in RDS security settings. So, our RDS instance can be only accessed within the VPC.

  • Click Security

42

  • Click Configure SSL

43

The domain name of our RDS instance will be displayed. Click OK. Also note down the domain name of our instance. This will be our MYSQL hostname

44

A new tab called Whitelist Settings will appear in the Security section.

  • Click add Whitelist Group

45

  • Group Name: ghostblog
  • Click Update ECS Instance IP Address. The private IP addresses of our ECS instances will be displayed

46

  • Choose the Instance IP
  • Click OK

47

Now our RDS instance has been successfully configured to be accessed from only our ECS instance.

Let's create a MySQL root account.

  • Click Accounts

48

  • Click on Create Master Account

49

  • Database Account name: root. This will be our MySQL username
  • Enter a STRONG PASSWORD for both Password and Confirm Password fields. This will be our MySQL password
  • Click Create

50

Step 7: Connecting to our Instance

Our ECS instance is also a computer located at Alibaba Cloud data center. It doesn't have a Graphical User Interface (You can install GUI if you want, It's not needed for deploying our ghost blog).

We can connect to our ECS instance in two ways. The first one is VNC and the other one is SSH.

F VNC vs SSH

VNC stands for Virtual Network Computing and SSH stands for Secure Shell. Both are used to connect to virtual servers like Alibaba Cloud ECS. VNC

VNC requires a high-speed internet connection whereas SSH works fine even in slow connections. However, SSH can't be used for accessing GUI.

If you have a high-speed internet connection go ahead with VNC. Or stick with SSH

Connecting to our instance via VNC

  • Log In to Alibaba Cloud Console
  • Click on Products
  • Click Elastic Compute Cloud under Elastic Computing section

51

  • Click Instances

52

  • Click Connect

53

A new browser tab will be opened and a six-digit password will be displayed.

  • Note down the VNC password.
  • Click Close

54

A new VNC session will be opened as follows. It will ask for our ECS instance's username password

55

Enter username as root followed by the password you entered in Step 2.

After successful login, you will be presented with the following screen

56

Now we've successfully connected to our ECS instance via VNC. We're ready to execute commands.

Connecting to our instance via SSH

Open your Terminal Application if you are using MacoS or Linux based Operating systems. If you're using Windows 10, open Command Prompt.

I'm using Enterprise edition of Microsoft Windows 10

  • Type cmd in the search bar & hit enter

57

Windows Command Prompt will be opened.

  • Type ssh

If you get the following output, you're ready to follow the next step.

58

Let's connect to our instance.

Type the following command. Don't forget to replace instace-ip with your instance's public IP address

ssh root@instace-ip

Accept the SSH fingerprint by typing yes

If the login was successful, you'll be presented with the following screen.

59

Step 8: Setting Up the hostname

echo "blog.sarathy.xyz" > /etc/hostname

The echo command is used to display text in the standard output. The > symbol redirects the output to the /etc/hostname file. Don't forget to replace sarathy.xyz with your domain name

[terminall]hostname -F /etc/hostname[/terminal]

The above command sets the Fully Qualified Domain Name(FQDN) to match our hostname.

60

Step 9: Setting Up an Unprivileged User

adduser sarathy

Replace sarathy with your own username.

Enter a STRONG PASSWORD for both password and confirm password fields. Skip the rest of the questions. Finally, answer Yes by pressing Y

61

We have successfully added an unprivileged user. In order to perform tasks that require root privileges, we have to add our newly created user to the sudoers group. The usermod command is used to achieve the task

Let's do it now

usermod -a -G sudo sarathy

62

Terminate the current SSH session by typing exit or by pressing Ctrl+D

Login to our ECS instance with the newly created user. To do that follow the same same steps exactly in Step 7. Don't forget to replace root with the newly created user.

Step 10: Upgrading the System to the Latest Version

The apt command in Ubuntu helps us to install, update or remove packages.

Let's update the package list

sudo apt update

After executing the above command, the number of packages that can be upgraded will be shown as follows

63

We're going the upgrade the entire system including programs and kernel to the latest version. The following command will do this. It may take some minutes to complete. Be patient & never interrupt the operation.

sudo apt dist-upgrade -y

When the operation is completed, we have to reboot our instance to boot the using the updated kernel. In Linux, the reboot command is used to reboot the system.

Reboot the system. Then log in again

Step 11: Setting the Default TimeZone

To match our local time with the instance's time, we have to configure the default Timezone.

Execute the following command to set our timezone

dpkg-reconfigure tzdata

Choose your timezone & hit Enter

The output would be similar to the following image

64

Step 12: Install Nginx

Nginx is a high-performance web server can be used for serving web pages, load balancing etc.

You can install Nginx by typing the following command

sudo apt install nginx -y

Verify the installation

nginx -v

The above command will display the currently installed version of Nginx

65

Let's start Nginx

sudo systemctl start nginx

Start Nginx during boot

sudo systemctl enable nginx

You'll get the following output

66

Step 13: Install Nodejs

Nodejs is a runtime environment for JavaScript

Install Nodejs by typing the following command

sudo apt install nodejs -y

Verify the installation

node -v

This will display the installed version of Nodejs as follows

67

Step 14: Install NPM

NPM stands for Node Package Manager. npm is used to install, upgrade or remove NodeJS packages.

Install npm by typing the following command

sudo apt install npm -y

Verify the installation

npm -v

The installed version of NPM will be displayed as follows

68

Step 15: Install Ghost-CLI

ghost-cli is an npm package used to manage Ghost blog. We'll install the latest version of Ghost-CLI globally using npm. Install it by typing.,

sudo npm install ghost-cli@latest -g

The installation may take several minutes. After the installation is successful, go ahead to the next step

69

Step 16: Deploying Our Blog

We have completed the essential steps for deploying our Ghost blog

Let's create a directory for saving our blog's resources. The mkdir command in Linux used to create directories

sudo mkdir -p /var/www/ghost

Change the ownership of the directory. Replace sarathy with your username. We'll use the chown command to change ownership

sudo chown -R sarathy:sarathy /var/www/ghost

Now we have to modify the file permission of the directory. The chmod command is used to modify file permission in Linux

sudo chmod 775 /var/www/ghost

70

Navigate to the installation directory by typing the following command. In Linux, the cd command is used to change directories. The pwd command is used to print the current working directory

cd /var/www/ghost

Start the Ghost Installer by typing,

ghost install

The installer will ask several questions.

First, the installer will warn us that MySQL is not installed. We need not to install MySQL in our ECS instance as we're using APsara for RDS as our MySQL server.

Ignore the warnig & continue the installation by pressing Yes

71

  • Enter Your Blog URL: Your Blog URL
  • Enter Your MySQL Hostname: Enter your RDS hostname we copied in Step 6
  • Enter Your MySQL Username: root
  • Enter Your MySQL Password: Enter your MySQL password we copied in Step 6
  • Enter Your Database Name: blog. Ghost installer will create a database named blog in our RDS instance

Then enter your instance's password to grant superuser rights to Ghost Installer

72

  • Do you wish to set up "ghost" MySQL user?: Yes Ghost installer will create a new MySQL user called "ghost"
  • Do you wish to setup Nginx? : Yes. Ghost installer will automatically configure Nginx for us
  • Do you wish to set up SSL?: Yes

Now Ghost installer will install a free SSL certificate provided Let's Encrypt and configure HTTPS for our blog. You'll be asked to enter an Email address. Lets Encrypt certificates have to be renewed every 90 days. Provide a valid Email address to receive certificate renewal reminders.

  • Do you wish to set up Systemd?: Yes
  • Do you want to start Ghost?: Yes

Once the installation is successful, you'll get the following message

73

Conclusion

In this article, we have shown you how to deploy a Ghost blog on Alibaba Cloud using ECS, RDS, VPC and Alibaba Cloud DNS. The installation is not yet completed. I will cover the rest in my next article. If you can't wait, Go to https://blog.your-domain.com/ghost to complete the installation.

If you have any questions or comments, feel free to ask in the comment section below.

0 1 1
Share on

Alibaba Clouder

2,605 posts | 747 followers

You may also like

Comments