tencent cloud

Feedback

Setting up a Ghost Blog

Last updated: 2024-01-06 17:43:10

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

    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.

    Directions

    Step 1 Logging in to a Linux instance

    Log in to a Linux instance using WebShell (recommended). You can also use other login methods that you are comfortable with:

    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.
    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.
    Note:
    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_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
    2. Run the following command to install Ghost.
    ghost install
    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.
    For issues regarding CVM login, see Password Login and SSH Key Login and Login and Remote Access.
    For issues regarding the CVM network, see IP Addresses and Ports and Security Groups.
    For issues regarding CVM disks, see System and Data Disks.
    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