This article is about installation of two Ghost blogs on a single domain. It consists of detailed steps for installation of Ghost, configuration of Nginx and startup scripts for setting up your blogs.

Ghost is a great platform for publishing your content to the world. While setting up Ghost(Pro) is fully automated and managed by Ghost, you may also self-host your Ghost instance by referring to setup guides provided by them.

I was able to setup one Ghost instance quickly by following the setup guide. However, I needed to setup a couple of them, one for me and the other for my brother. That was when I got to the bottom of it!

I spent long time trying out various options, that's why I thought of sharing it to save yours. Here's how I did to set them up...

1. Begin your setup

Follow the steps mentioned in this setup guide to install Ghosts on production environment.
I've listed some variations in these steps for installing two Ghost instances.

2. Creating directories

  • For each instance you need to create separate directory.
  • Choose your directory names for <blog1> and <blog2>.
  • You may install with same or different user for each instance.

Create separate directory for both instances

sudo mkdir -p /var/www/ghost/<blog1>
sudo mkdir -p /var/www/ghost/<blog2>

Assign ownership of directories to user

sudo chown <user>:<user> /var/www/ghost/<blog1>
sudo chown <user>:<user> /var/www/ghost/<blog2>

Set permissions to both the directories

sudo chmod 775 /var/www/ghost/<blog1>
sudo chmod 775 /var/www/ghost/<blog2>

3. Installation

  • Install Ghost into each directory by using CLI.

Navigate to first directory to install Ghost

cd /var/www/ghost/<blog1>
ghost install

Similarly for second one

cd /var/www/ghost/<blog2>
ghost install

4. Questions

  • You will be prompted with a number of questions during installation.
  • Following are the ones which need to be answered differently.

Ghost URL
Mention separate URL for each instance
? Enter your blog URL:<blog1>

Ghost database name
Mention separate database name for each instance. Although it should be automatically suggested by CLI.
? Enter your Ghost database name: <blog1>_prod

Choose to setup your own Nginx configuration
? Do you wish to set up Nginx? No

You may setup SSL manually later
? Do you wish to set up SSL? No

Startup script
Choose to have your own startup script
? Do you wish to set up Systemd? No
? Do you want to start Ghost? No

Note: Ghost should automatically setup first instance on default port 2368 and second one on 2369. You may check for ports in respective configuration files. Here /var/www/ghost/<blog1>/config.production.json

5. Custom Nginx config

  • Add following configuration to /etc/nginx/sites-available/default.
  • Make sure to restart Nginx server sudo service nginx restart.

location ^~ /<blog1> {
    alias /var/www/ghost/<blog1>;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_redirect off;

location ^~ /<blog2> {
    alias /var/www/ghost/<blog2>;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_redirect off;

6. Running Ghosts

  • Create a service to run Ghost instance.
  • Following are steps to create a service for running first Ghost instance.
  • Repeat these steps for second instance.

a. Create a service
sudo vim /etc/systemd/system/ghost-<blog1>.service

Copy+Paste following content to file and save

Description=Ghost systemd service for blog: <blog1>

ExecStart=/usr/bin/node /usr/bin/ghost run


b. Enable service
Reload systemd manager configuration
sudo systemctl daemon-reload

Enable service to start automatically at boot
sudo systemctl enable ghost-<blog1>.service

c. Running Ghost
Start Ghost via command
sudo systemctl start ghost-<blog1>

Check status of Ghost via command
sudo systemctl status ghost-<blog1>

To stop a Ghost instance use command
sudo systemctl stop ghost-<blog1>

d. Monitoring logs
Tail live logs via command
sudo journalctl -f -u ghost-<blog1>

Your two Ghost instances should be up and running now. Happy blogging!

In case of any questions or problems faced during installation, please mention in comments. I'll try my best to address them.