Hosting multiple Ghost blogs on Digital Ocean
2 min read

Hosting multiple Ghost blogs on Digital Ocean

Making the switch from Wordpress/PHP to Ghost/NodeJS was a good move. The site's faster, uses less resources and the hosting is much cheaper. There was only one downside: unlike the PHP hosting I've been used to, I had no idea how to host multiple blogs (with multiple domains) on the same droplet.

After some research, it turns out it's not that difficult. True, it's not as easy as cPanel makes it for PHP servers, but it's not rocket science either.

Digital Ocean has a very good tutorial about it. There's just one thing not mentioned there:

When you create the .conf files inside /etc/nginx/sites-enabled/, make sure you remove the default server.

For example, the .conf file for the main domain should start like this:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

The other .conf files cannot be default servers as well so this shorter version solves the problem:

server {
    listen 80;
    listen [::]:80;

It's something you need to be careful about, otherwise nginx won't start. Thankfully, someone pointed this out in the comments and I managed to fix my configuration. There are many other useful tips inside the comments as well, so it's a good idea to skim trough them if you have the time.

If you also need to host a static HTML site, like I wanted to, the steps that need to be followed are very similar and also much simpler.

For a more detailed tutorial, check out the one on Digital Ocean but if you want the TL;DNR version, here's what you need to do:

First you create a new .conf file inside /etc/nginx/sites-enabled/, with the following content.


server {
    listen 80;
    listen [::]:80;

    root /var/www/yoursite.com/public_html;
    index index.html index.htm;


    # Make site accessible from http://localhost/
    server_name yoursite.com;
}

Then, inside /var/www/ you create your domain directory. Just don't forget to add a public_html folder inside it, and place your files there, like I did.

Last but not least, do not forget to restart the nginx server, in order for the changes to take effect:
service nginx restart

In case you run into some problems with nginx, it's very helpful to check the log for errors:
sudo tail -30 /var/log/nginx/error.log

That's it! Now I'm the proud owner of a single droplet hosting two Ghost blogs and one static site!