tencent cloud


Setting up a Ghost Blog

Last updated: 2022-04-07 16:07:12


    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.


    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


    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. If the domain name is used for Mainland China service, ICP filing is required.


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

      usermod -aG sudo user
    7. 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.


    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

    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
    1. Run the following command to install Ghost.

      ghost install
    2. Use the following image to complete the installation process.

    3. Enter your blog URL: input your domain name in the format of http://your_domain_name.

    4. Enter your MySQL hostname: input your database address. Use localhost in this case and press Enter.

    5. Enter your MySQL username: input the username you use to connect to MySQL. Use root in this case and press Enter.

    6. Enter your MySQL password: input the corresponding password you set earlier and press Enter.

    7. Enter your database name: input the name of the database you created for Ghost in the previous step. Use ghost_data and press Enter.

    8. Input Y or n to complete the configuration.
      The admin URL appears on the bottom of the screen.

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

    10. Input desired information and click Last step, as shown below:

    11. You can invite others to create blogs, or skip this step.

    12. 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:


    If you encounter a problem when using CVM, refer to the following documents for troubleshooting based on your actual situation.

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support