All Products
Search
Document Center

Elastic Compute Service:Set up a Ghost blog

Last Updated:Dec 26, 2025

Ghost is a free, open source blogging platform built on Node.js that simplifies writing and publishing. This topic describes how to deploy a Ghost blog on an Elastic Compute Service (ECS) instance that runs Ubuntu 22.04 or later.

Background information

You can set up a Ghost blog in development or production mode. When you set up a Ghost blog for the first time, use development mode to make debugging easier. The procedure in this topic is intended for individual users who are new to building websites with Alibaba Cloud. For more information about Ghost, see Getting started with Ghost.

As your business grows, you can use Alibaba Cloud products to scale your service capacity horizontally and vertically. For example:

  • Scale up the CPU and memory of a single ECS instance to improve server processing power.

  • Add multiple ECS instances and use Server Load Balancer (SLB) to balance loads across them.

  • Use Auto Scaling to automatically add or remove ECS instances based on traffic.

  • Use Object Storage Service (OSS) to store static web pages and large numbers of images and videos.

Ghost has specific version requirements for Nginx, MySQL, and Node.js:

  • Nginx: 1.9.5 or later

  • MySQL: 8.0.x

  • Node.js: 22.x

For more detailed version requirements, see Prerequisites.

Preparations

Before you begin, make sure that your ECS instance meets the following requirements:

  • A public IP address is automatically assigned to the ECS instance. Alternatively, an elastic IP address (EIP) is associated with the ECS instance. For instructions on how to enable public bandwidth, see Enable public bandwidth.

  • Operating system: Ubuntu 22.04 or later.

  • An inbound rule is added to the security group of the instance to allow traffic on ports 22, 80, 443, and 2368. For more information, see Add a security group rule.

(Optional) Step 1: Create a new user

Note

If you already created an `ecs-user` when you set up the ECS instance, skip this step and use the `ecs-user` to perform Step 2: Install Nginx.

Ghost does not recommend using the root user directly. Therefore, you must create a new user and configure its permissions.

  1. Remotely log on to the ECS instance.

  2. Run the following command to create a new user.

    This example creates a user named test.

    adduser test
    1. At the New password: and Retype new password: prompts, enter and confirm a password. The password is not displayed by default. Press Enter when you are done.

    2. At the Enter the new value, or press ENTER for the default prompt, press Enter to keep the default settings. You can also enter user information as needed.

    3. At the Is the information correct? [Y/n] prompt, enter Y to confirm the information and press Enter to complete the setup.

    The configuration is similar to the following example.

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

    usermod -a -G sudo test
  4. Run the following command to switch to the test user.

    su - test

Step 2: Install Nginx

Important

Make sure that your ECS instance is associated with an auto-assigned public IP address or an EIP. For more information, see Associate or disassociate an EIP.

To deploy a Ghost blog, you must install Nginx as an HTTP server.

  1. Run the following commands to update the Linux operating system and software packages.

    sudo apt-get update
    sudo apt-get upgrade -y
  2. Install Nginx.

    sudo apt-get install -y nginx
  3. You can run the nginx -v command to check the Nginx version.

    nginx -v

    The output is similar to the following.

    nginx version: nginx/1.18.0 (Ubuntu)
    Note

    In this example, Nginx version 1.18.0 is installed. Software packages are updated periodically, so the Nginx version that you install may be different.

Step 3: Install MySQL

MySQL is an open source database management system. It is often installed as part of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It uses a relational database and Structured Query Language (SQL) to manage its data.

  1. Run the following command to install MySQL.

    sudo apt-get install -y mysql-server

    Run the mysql -V command to check the MySQL version number. An output similar to the following indicates that MySQL is installed successfully.

    test@iZbp1g2d4dpki2mf63b****:~$ mysql -V
    mysql  Ver 8.0.40-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
  2. Run the following command to connect to MySQL.

    sudo mysql
  3. Run the following command to create a database for Ghost.

    The example in this topic uses ghost_data.

    CREATE DATABASE ghost_data;
  4. Run the following command to set the password for the root user.

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your-root-password';
  5. Run the following command to reload the MySQL grant table to ensure that the permission changes take effect.

    FLUSH PRIVILEGES;
  6. Run the following command to exit MySQL.

    exit

Step 4: Install Node.js

Important

Ghost supports only Node.js 22.x LTS. This topic uses Node.js 22.x as an example.

  1. Download and import the Nodesource GPG key.

    sudo apt-get update
    sudo apt-get install -y ca-certificates curl gnupg
    sudo mkdir -p /etc/apt/keyrings
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
  2. Create a deb repository.

    NODE_MAJOR=22
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
  3. Update and install Node.js.

    sudo apt-get update
    sudo apt-get install -y nodejs
  4. Check the Node.js version.

    node -v

    The output is similar to the following.

    test@iZbp1g2d4dpki2mf63b****:~$ node -v
    v22.13.1

Step 5: Install Ghost

  1. (Optional) Change the npm registry to the Alibaba Cloud mirror to speed up the Ghost installation.

    Important

    Changing the npm registry might affect all future npm package installations. After you install Ghost, run npm config set registry https://registry.npmjs.org/ to restore the default npm configuration.

    npm config set registry https://registry.npmmirror.com
  2. Install the Ghost command-line interface (CLI) tool to quickly configure Ghost.

    sudo npm install ghost-cli@latest -g

    The output in the following figure indicates that the Ghost CLI tool is installed.

    image

  3. Run the following commands to create the Ghost installation directory and grant permissions on it.

    sudo mkdir -p /var/www/ghost
    sudo chown test:test /var/www/ghost
    sudo chmod 775 /var/www/ghost
  4. Run the following commands to install Ghost.

    cd /var/www/ghost
    ghost install

    During the Ghost installation, configure the following parameters. For other parameters, complete the configuration based on your needs and the on-screen prompts.

    Parameter

    Description

    Enter your blog URL

    Enter a resolved domain name, for example, http://example.com. This example uses a public IP address for testing: http://47.98.XX.XX.

    Enter your MySQL hostname:

    Enter the database endpoint. In this example, the MySQL database and Ghost are deployed on the same instance. Press Enter to use the default value.

    Enter your MySQL username:

    Enter the database username. Enter root and press Enter.

    Enter your MySQL password :

    Enter the database password. After you enter the password, press Enter.

    Note

    The database password is the one you set in Step 3.

    Enter your database name:

    Enter the name of the database for Ghost. Enter ghost_data and press Enter.

    Note

    The database name is the one you created in Step 3. This example uses ghost_data.

    saasa

    After the setup is complete, the Ghost administrator access URL is displayed at the bottom of the interface. For example: http://47.98.XX.XX/ghost.

  5. Test access to your Ghost blog.

    Follow these instructions to access the Ghost front-end homepage or back-end management page:

    • Front-end homepage

      On your local Windows host or any other Windows host with Internet access, open a browser and enter http://Public-IP-address-of-ECS-instance to access the Ghost front-end homepage.adada

      Note

      If a 502 error occurs, check for firewall issues within the instance. You can disable the firewall.

    • Back-end management page

      On your local Windows host or any other Windows host with Internet access, open a browser and enter http://Public-IP-address-of-ECS-instance/ghost to access the Ghost back-end management page.

      The first time you access the Ghost back-end management page, follow the on-screen prompts to complete the configuration of your Ghost blog.adad23

Domain name guidelines

If you want to build a website but do not have a domain name, you must purchase one first. If your website is hosted on a server in the Chinese mainland, you must complete an ICP filing for the domain name before you resolve it to the ECS instance where the website is deployed. The following sections provide operational guidelines:

  • Purchase a domain name

    You can set a unique domain name for your website. This allows visitors to access your website using an easy-to-remember domain name instead of a complex IP address.

    Log on to Alibaba Cloud to purchase a domain name. For more information, see Domain name registration.

  • ICP filing

    For websites whose domain names point to servers in the Chinese mainland, an ICP filing is mandatory. The website cannot be made accessible until an ICP filing number is obtained.

  • Domain name resolution

    You must resolve your domain name in Alibaba Cloud DNS so that visitors can access your website using the domain name. For more information, see Beginner's guide.