Setting up a Ghost Blog

Last updated: 2020-03-06 11:10:11

PDF

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.

To setup Ghost, you should be familiar with Linux and its common commands, such as Install Software via Apt-get under Ubuntu Environment.

Software

This article uses the following software:

  • Linux operating system. This article uses Ubuntu 18.04.
  • Nginx 1.14.0 is used to provide web service.
  • MySQL 5.7.27 is used for database.
  • Node.js 10.17.0 is our runtime environment.
  • Ghost 3.0.2

Prerequisites

You should have a Linux CVM. If you have not purchased one yet, see Getting Started with Linux CVMs.

  • A domain name that points to your CVM and already completed ICP filing.

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.

    Do not use ghost as the username. It causes conflicts with Ghost-CLI.

    adduser user
    1. Input and confirm password as prompted. Password is not shown by default. Press Enter to continue.
    2. Input user information. Or press Enter to skip them and continue.
    3. Input Y to confirm and press Enter to complete the process, as shown below:
  3. Run the following command to add user privileges.
    usermod -aG sudo user
  4. Run the following command to switch to user user.
    su user

Step 3 Update installed packages

Run the following commands to update installed packages.

Input the password for user as prompted and press Enter to start.

sudo apt-get update
sudo apt-get upgrade -y

Step 4 Environment setup

Install Nginx

Run the following command to install Nginx.

sudo apt-get install -y nginx 

Install and configure MySQL

  1. Run the following command to install MySQL.
    sudo apt-get install -y mysql-server 
  2. Run the following command to connect to MySQL.
    sudo 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.
    \q

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_10.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

Step 5 Install and configure Ghost

  1. Run the following commands.
    sudo mkdir -p /var/www/ghost
    sudo chown user:user /var/www/ghost
    sudo chmod 775 /var/www/ghost
    cd /var/www/ghost
  2. Run the following command to install Ghost.
    ghost install
  3. Use the following image to complete the installation process.
    1. Enter your blog URL: input your domain name in the format of http://your_domain_name.
    2. Enter your MySQL hostname: input your database address. Use localhost in this case and press Enter.
    3. Enter your MySQL username: input the username you use to connect to MySQL. Use root in this case and press Enter.
    4. Enter your MySQL password: input the corresponding password you set earlier and press Enter.
    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.
    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.