Ghost is a free open source blogging platform developed based on Node.js. The platform is used to simplify the online publishing process for individual blogs and online publications. This topic describes how to deploy the Ghost blogging platform on an ECS instance that runs CentOS 7.


An Alibaba Cloud account is created. To create an Alibaba Cloud account, go to the Alibaba Cloud official website.

Background information

You can use Alibaba Cloud services to scale up and scale out your service capacity. For example, you can optimize your business by using the following ways:
  • Scale up the vCPUs and memory of a single ECS instance to enhance the processing performance.
  • Add multiple ECS instances and implement load balancing among these instances.
  • Use Auto Scaling to automatically increase or decrease the number of ECS instances.
  • Use Object Storage Service (OSS) to store a large amount of data such as static web pages, pictures, and videos.

An ecs.c6.large ECS instance is used in the examples of this topic to build the Ghost blogging platform. The procedure described in this topic is applicable to individual users that are new to website construction with ECS instances.

Notice You can build the Ghost blogging platform in development or production mode. We recommend that you use the development mode for ease of debugging if you are building the Ghost blogging platform for the first time.


Step 1. Create a Linux ECS instance

This section describes how to create an ECS instance. To build an individual website, you need only one ECS instance.
Before you configure parameters, take note of the following items:
  • Instance Type: For an individual website, you can use the 1 vCPU and 2 GiB or 2 vCPUs and 4 GiB instance type. For more information about instance types, see Instance families.
  • Network Type: Select VPC.
  • Bandwidth pricing: Assign Public IP Address is selected in this topic. If you do not select Assign Public IP Address, the instance is not assigned a public IP address. If you want to enable the ECS instance to access the Internet, you must create an Elastic IP address (EIP) and associate the EIP with the ECS instance. The actual configuration depends on your requirements.
  • Image: A Linux image, such as CentOS 7.2 64-bit, in the public image list is used in this topic.

After you create the instance, the system sends you a text message and an email to notify you of the information about the instance, such as the instance name, public IP address, and internal IP address. You can use the information to log on to the ECS console and manage the instance.

The system notifies you of important information by sending text messages. To authenticate some important operations such as restarting or stopping the instance, you must use your mobile phone to receive verification codes. Therefore, after you bind a mobile number to your Alibaba Cloud account, you must keep the corresponding mobile phone in the normal running status.

Step 2. Deploy the web environment

This section describes how to deploy the web environment by installing NGINX.

  • Your instance is able to connect to the Internet.
  • A tool for connecting to the Linux ECS instance is installed, such as SecureCRT.

To deploy the web environment, follow these steps:

  1. Open the SecureCRT client and specify the information of the ECS instance to which you want to log on.
    1. Specify the name of the session for connecting to the instance.
    2. Select SSH from the Protocol drop-down list.
    3. Enter the host IP address in the Hostname field and specify the username.
    4. Click Connect.
    Configure the logon information
  2. Enter the root username and the password.
    Enter the username and password
  3. Add the NGINX repository.
    rpm -Uvh
    The software package provides NGINX 1.10.2.
    Note The actual version may vary depending on the package that you downloaded.
  4. Install NGINX.
    yum -y install nginx
  5. Enable NGINX to run at system startup.
    systemctl enable nginx.service
  6. Start NGINX and check the NGINX service status.
    systemctl start nginx.service
    systemctl status nginx.service
  7. Enter the public IP address of the ECS instance in the address bar of your browser to view the default NGINX web page.
    NGINX web page

Step 3. Install Ghost

  1. Run the following command to update system software to the latest version:
    yum -y update
  2. Install Node.js.
    1. Install Extra Packages for Enterprise Linux (EPEL).
      yum install epel-release -y
    2. Install Node.js and npm.
      yum install nodejs npm --enablerepo=epel
    3. Install the package manager for Node.js.
      npm install -g n
    4. Install Node.js of a stable version.
      Node.js 12.16.3 is used in this example.
      n 12.16.3
    5. Run the n command to select Node.js 12.16.3.
    6. Edit the environment configuration file.
      vim ~/.bash_profile
    7. Enter i to switch to the edit mode and add the following information to the end of the file:
      export N_PREFIX=/usr/local/bin/node
      export PATH=$N_PREFIX/bin:$PATH
      After the editing is completed, press the Esc key to exit the edit mode and enter :wq to save and close the file.
    8. Run the following command to apply the configuration:
      source ~/.bash_profile
    9. Install the process manager to control Node.js applications.
      This process manager keeps the applications in the running state.
      npm install pm2 -g
    10. Run the node -v and npm -v commands to check the Node.js version.
  3. Install Ghost.
    1. Create a directory to which to install Ghost.
      mkdir -p /var/www/ghost
    2. Go to the Ghost installation directory, and run the following command to download the latest Ghost package:
      cd /var/www/ghost
    3. Decompress the Ghost package.
      yum install unzip -y
    4. Install GCC and C++ compilers.
      yum -y install gcc gcc-c++
    5. Use npm to install Ghost.
      npm install -production
    6. Run the npm start command to start Ghost and check whether Ghost is installed.
      If Ghost is started, the following command output is displayed. You can press Ctrl+C to close Ghost.
      [2020-04-13 04:00:01] INFO Ghost is running in development...
      [2020-04-13 04:00:01] INFO Listening on:
      [2020-04-13 04:00:01] INFO Url configured as: http://121.196. *. */
      [2020-04-13 04:00:01] INFO Ctrl+C to shut down
      [2020-04-13 04:00:01] INFO Ghost boot 2.185s
    7. Modify the config.development.json file in the /var/www/ghost/core/server/config/env directory.
      vi /var/www/ghost/core/server/config/env/config.development.json
    8. Set the domain name of Ghost to the URL in the config.development.json file.
      ghost1Press the Esc key to exit the edit mode and enter :wq to save and close the file.
  4. Specify NGINX as the reverse proxy for Ghost.
    1. Go to the NGINX configuration directory.
      cd /etc/nginx/conf.d/
    2. Create the NGINX configuration file for Ghost.
      vim /etc/nginx/conf.d/ghost.conf
    3. Add the following content to the ghost.conf file, and set server_name to the domain name of Ghost that is used in your actual runtime environment.
      upstream ghost {
      server {
          listen      80;
          access_log  /var/log/nginx/ghost.access.log;
          error_log   /var/log/nginx/ghost.error.log;
          proxy_buffers 16 64k;
          proxy_buffer_size 128k;
          location / {
              proxy_pass  http://ghost;
              proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
              proxy_redirect off;
              proxy_set_header    Host            $host;
              proxy_set_header    X-Real-IP       $remote_addr;
              proxy_set_header    X-Forwarded-For $proxy_add_X_forwarded_for;
              proxy_set_header    X-Forwarded-Proto https;
    4. Change the name of the default configuration file default.conf to default.conf.bak, so that NGINX is applicable only to ghost.conf.
      mv default.conf default.conf.bak
    5. Restart NGINX.
      systemctl restart nginx.service
  5. Start Ghost.
    cd /var/www/ghost/
    npm start
  6. Connect to the Ghost blogging platform.
    1. Enter the URL http://<IP address of the ECS instance> or http://<Domain name of the Ghost blogging platform> in the address bar of your browser to connect to the Ghost blogging platform.
      Ghost web page
      Note If the system returns Error Code 502, check whether the firewall is disabled.
    2. To edit your Ghost blogging platform, enter the URL http://<IP address of the ECS instance/ghost> in the address bar of your browser.
      Edit the Ghost blogging platform

Step 4. Purchase a domain name

You can specify a unique domain name for your website. Therefore, users can visit your website by using a simple domain name instead of a complex IP address.

We recommend that you go to Alibaba Cloud to purchase a domain name.

  1. Go to the Domains page, enter the domain name that you want to use in the search bar, and then click Find A Domain. If the searched domain name is not registered, you can purchase it. Specify the domain name that you want to purchase and the service duration, and click Buy Now.
  2. When you confirm the order, you must specify the Owner of Domain Name parameter.
    To simplify the operation, we recommend that you select Person. You can change the owner later. Person is selected in this topic.
  3. If you purchase the domain for the first time, you must create the registrant profile. For more information, see Create the registrant profile.
  4. Enter the authentic registration information.
  5. Complete the real-name verification after you specify the information. Upload the scanned picture of your identity card. The profile verification takes three to five weekdays.

Step 5. Apply for an ICP filing

You must apply for an ICP filing for the domain name that is associated with a website hosted on a server in mainland China. Your website cannot provide services until you obtain the ICP license number for the domain name.

Alibaba Cloud ICP Filing System can help you simplify the ICP filing procedure. You can apply for an ICP filing free of charge. Typically, the review takes about 20 days.

  1. Log on to the ICP Filing Management console.
  2. In the left-side navigation pane, click ICP No. Application. On the page that appears, click Apply in the Operation column corresponding to the ECS instance that you have purchased to apply for an ICP number. This number will be used for the ICP filing application.
  3. In the message that appears, click OK.
  4. After your application is approved, the ICP No. Management page appears and the ICP number associated with the ECS instance is displayed. For more information about ICP filings, click the Filing Introduction tab.
  5. If you apply for an ICP filing for the first time, you must register an ICP filing account in Alibaba Cloud ICP Filing System.
    Note The ICP filing account is not an Alibaba Cloud account and can be used only for ICP filings.

Step 6. Resolve the domain name to the IP address of the instance

You must resolve the domain name to the IP address of the ECS instance, so users can visit your website by using the domain name. Follow these steps:

  1. Log on to the Domains console.
  2. In the left-side navigation pane, click Domain Names. On the page that appears, find the domain name that you want to resolve and click Resolve in the Actions column.
  3. Click Getting Started.
  4. Enter the public IP address of your Linux instance in the dialog box that appears, and click Submit.