How to host multiple Ghost instances on a single server

Ghost is great and simple to use blogging platform, with clean and easy to use interface, having just the options that every user need in order to create and maintain their blog. In this tutorial we will discuss how to have more ghost instance on a single Ubuntu server, each of them completely independent having its own content and specific settings. We are assuming that we already have one ghost single instance properly running for our domain my-first-blog.com using Nginx as web server.

Before we proceed to add our second ghost instance, it is better if we stop the related servers that are running:

# service ghost stop
# service nginx stop

Now that we have the services stopped, first we need to modify nginx configuration. While having one instance, we were using on default nginx configuration file for our website. Now, we must have separate configuration file for every ghost instance that we are going to host on our server. We change to nginx configuration folder and execute the following commands:

# cd /etc/nginx/sites-enabled
# mv default my-first-blog.com
# cp my-first-blog.com my-second-blog.com

Now, we need to open both files using our favorite editor and edit the server_name directive to match our domain name. For the first file, we should have:

server_name my-first-blog.com

Similar, in the second file, we should have:

server_name my-second-blog.com

Another parameter that we need to change is the port on which nginx connects to ghost. By default, when we have one instance, all traffic is sent to one port. We can use any port number higher than 1024 that is currently not in use. Let’s pick the first one, 1025, open my-second-blog.com configuration file in our favorite editor and change to port parameter as follows:

proxy_pass http://localhost:1025

We are done with nginx configuration modification, so we can start Nginx

# service nginx start

Now, we need to configure ghost. First, we need to go to the /var/www directory and create separate folder for each Ghost instance:

# cd /var/www/
# mkdir my-first-blog.com
# mkdir my-second-blog.com

Then, we need to copy the content of the ghost directory in each of the newly created folders:

# cp -r ghost my-first-blog.com
# cp -r ghost my-second-blog.com

Next, we need to locate config.js file which is inside ghost/ directory. For the first site, file location is /var/www/my-first-blog.com/ghost/config.js and we need to change the URL parameter only, so it looks as follows:

production: {
    url: 'http://my-first-blog.com'

For the second blog, file location is /var/www/my-second-blog.com/ghost/config.js and we need to change the URL and port parameter as well, so it looks as follows:

production: {
    url: 'http://my-second-blog.com'
...
    port: '1025'

Now we are done with the configuration. We need to create a way to easy start/stop each Ghost instance. In order to do that, we will create separate file inside /etc/init directory for each instance. For example, for our first blog, we will have the file /etc/init/ghost-my-first-blog.conf with the following content:

start on startup

script
    cd /var/www/my-first-blog.com/ghost
    npm start --production
end script

Similar, for the second file, we will have the file /etc/init/ghost-my-second-blog.conf with the following content:

start on startup

script
    cd /var/www/my-second-blog.com/ghost
    npm start --production
end script

After this is saved, we can start the blogs with

# service ghost-my-first-blog start
# service ghost-my-second-blog start

As long as we are using different port number, we can repeat this procedure as many times as we need and have multiple blog instances hosted on our server.

Try this tutorial on an SSD cloud server for $5.00/month only!

Built for Developers: 512MB RAM, 20GB SSD Disk and 2TB Transfer. 30 second setup.