Ghost is a free, open source blogging platform developed based on Node.js. This platform is used to simplify the process of writing and publishing blogs. This article describes how to set up a Ghost site on an Elastic Compute Service (ECS) instance that runs Ubuntu 20.04.
Ghost sites can run in development or production mode. The first time you set up a Ghost site, we recommend that you run the site in development mode to make the site easy to debug. The procedure described in this article is applicable to individual users who are new to using Alibaba Cloud to build websites. For more information about Ghost sites, see Getting started with Ghost.
You can use Alibaba Cloud services to scale up or out your service capacity based on your business needs. Examples:
• Scale up the vCPUs and memory of a single ECS instance to enhance the processing performance of the instance.
• Add multiple ECS instances to the backend server groups of a Server Load Balancer (SLB) instance and use the SLB instance to load-balance the traffic to ECS instances.
• Use Alibaba Cloud Auto Scaling to automatically increase or decrease the number of ECS instances on demand.
• Use Object Storage Service (OSS) buckets to store large volumes of data, such as static web pages, pictures, and videos.
An ECS instance that uses the following configurations is created:
• The instance has a public IP address or an elastic IP address (EIP). For more information, see Associate an EIP.
• Operating system: Ubuntu 16.04, 18.04, 20.04, or 22.04.
Note: In this article, an ECS instance that runs Ubuntu 20.04 is used. Software package versions may vary slightly based on Ubuntu versions.
• An inbound rule is added to a security group of the ECS instance to open port 22, port 80, port 443, and port 2368. For more information, see Add a security group rule.
Note: If you configured ecs-user as the logon username of the ECS instance during instance creation, skip this step and proceed to Step 2: Install NGINX.
Ghost recommends that you do not use the root user to build the Ghost site. Create a user on the ECS instance and grant permissions to the user.
1. Log on to the ECS instance remotely.
For more information, see Connect to a Linux instance by using a password or key.
2. Run the following command to create a new user: In this example, the test
user is created.
adduser test
a) When the New password:
and Retype new password:
messages appear, enter and confirm a password. By default, the characters of the password are hidden when you enter the password. After you confirm the password, press the Enter
key.
b) When the Enter the new value, or press ENTER for the default
message appears, press the Enter
key to accept the default value. Alternatively, you can also fill in the user information according to the actual situation.
c) When the Is the information correct? [Y/n]
message appears, enter Y
to confirm the information and press the Enter
key to complete the configuration.
The following code shows how to configure a new user:
root@iZbp1g2d4dpki2mf63b****:~# adduser test
Adding user `test' ...
Adding new group `test' (1000) ...
Adding new user `test' (1000) with group `test' ...
Creating home directory `/home/test' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for test
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
3. Run the following command to add the new user to a group:
usermod -a -G sudo test
4. Run the following command to switch to the test
user:
su - test
Note: Make sure that your ECS instance is assigned a public IP address or bound with an Elastic IP Address address (EIP). For more information, see Associate an EIP.
To build a Ghost site, you must install NGINX to use it as an HTTP server.
1. Run the following commands in sequence to update the Linux operating system and software package.
sudo apt-get update
sudo apt-get upgrade -y
2. Install NGINX.
sudo apt-get install -y nginx
After NGINX is installed, run the nginx –v
command to check the version of NGINX.
test@iZbp1g2d4dpki2mf63b****:$ nginx -v
nginx version: nginx/1.18.0 (Ubuntu)
Note: In this example, NGINX 1.18.0 is installed. The software installation package is updated from time to time. The version of NGINX that you install may be different.
MySQL is an open source database management system and is often installed as part of the popular LAMP (Linux, Apache, MySQL, and PHP/Perl/Python) stack. MySQL uses relational databases and SQL statements to manage data.
1. Run the following command to install MySQL:
sudo apt-get install -y mysql-server
Run the mysql –V
command to check the version of MySQL. A command output similar to the following one indicates that MySQL is installed.
test@iZbp1g2d4dpki2mf63b****:~$ mysql -V
mysql Ver 8.0.33-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
2. Run the following command to connect to MySQL:
Ubuntu 18.04/20.04/22.04
sudo mysql
Ubuntu 16.04
mysql -u root -p
3. Run the following command to create a database for Ghost:
In this example, a database named ghost_data is created.
CREATE DATABASE ghost_data;
4. (Optional) If the ECS instance runs Ubuntu 18.04, 22.04, or 22.04, run the following command to configure the password of the root
user:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Enter the password for the root user',
5. Run the following command to exit MySQL:
exit
Before you install Ghost, install Node.js that is required for Ghost.
1. Run the following command to download the Node.js installation source:
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash
2. Run the following command to install Node.js:
sudo apt-get install -y nodejs
3. Run the following command to view the Node.js version:
node -v
A command output similar to the following one is returned:
test@iZbp1g2d4dpki2mf63b****:~$ node -v
v16.20.1
1. Install the Ghost-CLI command line tool to quickly configure Ghost.
sudo npm install ghost-cli@latest -g
2. Run the following commands in sequence to create a directory in which to install Ghost and grant permissions on the directory:
sudo mkdir -p /var/www/ghost
sudo chown test:test /var/www/ghost
sudo chmod 775 /var/www/ghost
3. Run the following commands in sequence to install Ghost:
cd /var/www/ghost
ghost install
Some parameters must be specified during the Ghost installation process, as shown in the following figure.
Description of the parameters:
http://exapmle.com
.In this example, http://47.98.XX.XX
is entered.
Enter
key to accept the default value because the MySQL database and Ghost are installed on the same ECS instance.Enter
key. In this example, root
is entered.Enter
key.Note: The password used to connect to the database is the password that you set in Step 3.
Enter
key.Note: The name of the database is the name that you set in Step 3. In the example, the name is ghost_data
.
Configure other parameters as instructed based on actual scenarios. After the configuration is complete, the access address for the Ghost administrator is displayed in the lower part of the page. In this example: http://47.98.XX.XX/ghost
is displayed.
4. Test the access to the Ghost site.
Perform the following operations to access the frontend homepage or the backend management page of Ghost:
a) Front homepage
On your Windows computer or a Windows computer that has Internet connectivity, open a browser and enter the <Public IP address of the ECS instance>
in the address bar to access the frontend homepage of Ghost.
Note: If Error Code 502 occurs, check whether an exception occurs on the firewall of the ECS instance. You can disable the firewall.
b) Background management page
On your Windows computer or a Windows computer that has Internet connectivity, open a browser and enter <Public IP address of the ECS instance>/ghost
in the address bar to access the backend management page of Ghost.
The first time you access the backend management page of Ghost, follow the instructions to complete the configurations of Ghost.
If you want to build a website but do not have your own domain name, purchase a domain name. After you purchase a domain name, If your website is deployed on an ECS instance within the Chinese mainland, apply for an Internet Content Provider (ICP) filing for the domain name and resolve the domain name to the public IP address of the ECS instance. Perform the following operations:
• Purchase a domain name
You can specify a unique domain name for your website. This allows users to visit your website by using an easily identifiable domain name instead of a complex IP address. We recommend that you purchase a domain name from Alibaba Cloud. For more information, see Register a domain name on Alibaba Cloud.
• Apply for an ICP filing for the domain name
Apply for an ICP filing for the domain name that is associated with a website hosted on an ECS instance within the Chinese mainland. Your website cannot provide services until you obtain an ICP filing number for the domain name.
• Resolve the domain name
Use Alibaba Cloud DNS to resolve the domain name to the IP address of the ECS instance on which the website is deployed. This way, users can visit your website by using the domain name. For more information, see Get Started with Alibaba Cloud DNS.
1,013 posts | 247 followers
FollowAlibaba Clouder - December 19, 2018
Alibaba Clouder - May 5, 2019
Alibaba Clouder - May 6, 2019
Alibaba Clouder - May 6, 2019
Alibaba Clouder - October 30, 2018
Alibaba Cloud Community - December 23, 2021
1,013 posts | 247 followers
FollowElastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreAlibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn MoreHigh Performance Computing (HPC) and AI technology helps scientific research institutions to perform viral gene sequencing, conduct new drug research and development, and shorten the research and development cycle.
Learn MoreA HPCaaS cloud platform providing an all-in-one high-performance public computing service
Learn MoreMore Posts by Alibaba Cloud Community