Scenario
Ghost is a free and open source blogging platform written in JavaScript and distributed under the MIT License, designed to simplify the process of online publishing for individual bloggers as well as online publications. This article describes how to setup Ghost on a CVM.
Software
This article uses the following software:
Linux operating system. This article uses Ubuntu 20.04.
Nginx 1.18.0 is used to provide web service.
MySQL 8.0.25 is used for database.
Node.js 14.17.0 is our runtime environment.
Ghost 4.6.4
Prerequisites
A domain name that points to your CVM. If the domain name is used for Mainland China service, ICP filing is required.
Directions
Step 1 Logging in to a Linux instance
Step 2 Create a new user
1. After logging in, switch to root
. Refer to this article for details. 2. Run the following command to create a user named user
.
Note:
Do not use ghost
as the username. It causes conflicts with Ghost-CLI.
3. Input and confirm password as prompted. Password is not shown by default. Press Enter to continue.
4. Input user information. Or press Enter to skip them and continue.
5. Input Y to confirm and press Enter to complete the process, as shown below:
6. Run the following command to add user privileges.
7. Run the following command to switch to user user
.
Step 3 Update installed packages
Run the following commands to update installed packages.
Note:
Input the password for user
as prompted and press Enter to start.
Step 4 Environment setup
Install Nginx
Run the following command to install Nginx.
sudo apt-get install -y nginx
1. Run the following command to install MySQL.
sudo apt-get install -y mysql-server
2. Run the following command to connect to MySQL.
3. Run the following command to create a database for Ghost named ghost_data
.
CREATE DATABASE ghost_data;
4. Run the following command to set a password for the database user root
.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
5. Run the following command to quit MySQL.
Install Node.js
1. Run the following command to set a default Node.js version to be used.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash
2. Run the following command to install Node.js.
sudo apt-get install -y nodejs
Install Ghost-CLI
Run the following command to install Ghost-CLI which helps configuring Ghost.
sudo npm install ghost-cli@latest -g
1. Run the following commands.
sudo mkdir -p /var/www/ghost
sudo chown user:user /var/www/ghost
sudo chmod 775 /var/www/ghost
2. Run the following command to install Ghost.
3. Use the following image to complete the installation process.
3.1 Enter your blog URL: input your domain name in the format of http://your_domain_name
.
3.2 Enter your MySQL hostname: input your database address. Use localhost
in this case and press Enter.
3.3 Enter your MySQL username: input the username you use to connect to MySQL. Use root
in this case and press Enter.
3.4 Enter your MySQL password: input the corresponding password you set earlier and press Enter. 3.5 Enter your database name: input the name of the database you created for Ghost in the previous step. Use ghost_data
and press Enter. 3.6 Input Y or n to complete the configuration.
The admin URL appears on the bottom of the screen.
4. Open a browser window on your local machine and visit the admin URL to start configuring your blog.
Click Create your account to create an admin account.
5. Input desired information and click Last step, as shown below:
6. You can invite others to create blogs, or skip this step.
7. Go to the administration page to manage blogs, as shown below:
Once finished, use a browser to visit your domain name www.xxxxxxxx.xx
to see your blog, as shown below:
FAQ
If you encounter a problem when using CVM, refer to the following documents for troubleshooting based on your actual situation.
Was this page helpful?