Install Ghost (CMS) Blog Publishing Platform on Debian and Ubuntu


Introduction

In the world of blogging, content management systems (CMS) play a vital role in managing and publishing articles. One popular CMS that has gained significant traction among bloggers is Ghost. Ghost is an open-source platform built on Node.js, known for its simplicity, speed, and elegant design. In this article, we will explore how to install Ghost on both Debian and Ubuntu operating systems. We will provide step-by-step instructions along with examples and their respective outputs to guide you through the installation process.

Prerequisites

Before we begin, make sure you have the following prerequisites −

  • A server or virtual machine running either Debian or Ubuntu.

  • Node.js installed on your system.

  • NPM (Node Package Manager) installed.

Step 1: Update System Packages

To ensure that your system has the latest updates, open the terminal and run the following command −

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and NPM

Ghost requires Node.js and NPM to be installed on your system. Run the following commands to install them −

sudo apt install -y curl
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install -y nodejs

To verify the installation, run the following commands −

node --version
npm --version

You should see the versions of Node.js and NPM printed on the screen.

Step 3: Install Ghost-CLI

Ghost-CLI is a command-line tool that helps in installing and managing Ghost instances. Install Ghost-CLI globally by running the following command −

sudo npm install -g ghost-cli@latest

Step 4: Create a Directory for Ghost

Choose a directory where you want to install Ghost. For this example, let's create a directory named "my-ghost-blog" in the home directory. Use the following command to create the directory −

mkdir ~/my-ghost-blog

Step 5: Install and Setup Ghost

Navigate to the directory you created in the previous step using the following command −

cd ~/my-ghost-blog

Run the following command to install Ghost −

ghost install

The Ghost installation wizard will guide you through the setup process. Here are the prompts you will encounter −

  • Enter your blog URL (e.g., https://your-blog.com) − example.com

  • Enter your MySQL hostname − localhost

  • Enter your MySQL username − ghost_user

  • Enter your MySQL password −

  • Enter your database name − ghost_db

  • Do you wish to set up "ghost" MySQL user? Yes/No − Yes

  • Do you wish to set up Nginx? Yes/No − Yes

  • Do you wish to set up SSL? Yes/No − No

Please note that you should replace the example values with your actual information when prompted.

Step 6: Start Ghost

After the installation is complete, start Ghost using the following command −

ghost start

Ghost will start running on your server, and you can access it by opening your web browser and entering your blog's URL.

Step 7: Configure Ghost for Production

By default, Ghost is installed in development mode. However, for a production environment, it is recommended to configure Ghost to run in production mode. To do this, follow these steps −

Open the Ghost configuration file using a text editor −

sudo nano /var/www/ghost/config.production.json

Locate the "development" line and change it to "production".

Save the file and exit the text editor.

Restart Ghost for the changes to take effect −

ghost restart

Ghost is now configured to run in production mode, providing better performance and security for your blog.

Step 8: Setting Up Additional Domains

If you want to host multiple domains or subdomains on your Ghost installation, you can easily set them up. Here's how −

Open the Nginx configuration file for your Ghost installation −

sudo nano /etc/nginx/sites-available/your-domain.conf

Inside the server block, add a new server block for each additional domain or subdomain you want to set up −

server {
   listen 80;
   server_name additional-domain.com;

   location / {
      proxy_pass http://localhost:2368;
      proxy_set_header Host $host;
      proxy_buffering off;
   }
}

Replace additional-domain.com with your actual domain or subdomain.

Save the file and exit the text editor.

Create a symbolic link to enable the additional domain configuration −

sudo ln -s /etc/nginx/sites-available/your-domain.conf /etc/nginx/sites-enabled/

Test the Nginx configuration to make sure there are no syntax errors −

sudo nginx -t

If the test is successful, restart Nginx to apply the changes −

sudo systemctl restart nginx

You can now access your Ghost blog using the additional domain or subdomain.

Step 9: Updating Ghost

To keep your Ghost installation secure and up to date, it's important to regularly update it. Here's how to update Ghost using the Ghost-CLI −

SSH into your server or open a terminal.

Navigate to your Ghost installation directory −

cd /var/www/ghost

Run the following command to update Ghost to the latest version −

ghost update

Ghost-CLI will automatically check for updates, download the latest version, and perform the necessary steps to update your installation.

Step 10: Securing Ghost with Let's Encrypt SSL Certificate

To secure your Ghost blog with an SSL certificate from Let's Encrypt, follow these steps −

Install Certbot, a tool for obtaining and managing SSL certificates −

sudo apt install -y certbot

Run the following command to obtain and install the SSL certificate −

sudo certbot --nginx -d your-domain.com

Replace your-domain.com with your actual domain.

Certbot will guide you through the certificate installation process, including selecting the appropriate Nginx server block and redirecting HTTP traffic to HTTPS.

Once the installation is complete, Certbot will automatically configure Nginx to use the SSL certificate.

Test your SSL configuration by visiting your blog using https://your-domain.com.

Congratulations! Your Ghost blog is now secured with an SSL certificate.

Conclusion

In this article, we explored the step-by-step process of installing Ghost (CMS) on Debian and Ubuntu operating systems. We covered the prerequisites, installation of Node.js and NPM, installation of Ghost-CLI, and the complete setup of Ghost using the command-line interface. By following these instructions, you can have your own Ghost blog up and running in no time. Ghost's simplicity and elegant design make it an excellent choice for bloggers looking for a fast and efficient publishing platform. Happy blogging!

Updated on: 17-Jul-2023

326 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements