How to setup a Ghost blog

After choosing a blog engine and exported my content from my old blog, I started to think about how I'm going to take my blog to production (aka internet).

I chose Digital Ocean as the hosting service. I Highly recommend it. Simple to use and setup. It's also blazing fast, even in minimal configuration.

There are many articles explaining how to deploy Ghost on every platform you can think of, so I would like to share with you the resources I used and share some tips that helped me pave the way to production.

Setup

First thing you need to do is to chose OS. I chose Ubuntu with the advice of a couple of our IT guys, but you can chose whatever OS (linux based) you fell comfortable with.
I used the built-in image Digital Ocean has with Ubuntu 14.04.
Anyway, make sure your server is protected against the Shellshock Bash Vulenrability.

Next, you need to do is to install NodeJS. This article explains how to install NodeJS on Ubuntu.
I used the NVM option since it gives more flexability of chosing the NodeJS version, since the Ghost guys recommend using NodeJS 0.10.3 with NPM 1.4.21.

Then, you need to install Ghost. This article explains how to install it with nginx, which will give you more flexability maintaining your blog (splash on upgrade, SSL, static files caching, etc...).

Now, you need to configure a DNS so your blog will be accessable to the internet. I used this article which also explains more about what DNS is in more detail. Also make sure you configure your domain name in the nginx ghost configuration file you created earlier.

And you are done - you now have a working Ghost blog!

SSL

Admin access to your blog should be SSL protected. You don't have to, but take into account that your blog will be more vulnerable to attacks.

First, you need to purchase a certificate. This article gives you some options for purchasing a relatively cheep certificate. I choose Namecheap since thr price is reasonable and the protection is what i think is the minimal I needed.

I found this post which explains in detail how to configure the certificate with nginx.

I also recommend to configure an automatic redirect of the admin panel URLs from http to https. You can use this post in order to configure it in nginx.

Recently many issues came up with the SSL protocol so make sure you check and configure your server correctly: POODLE, SHA-2 migration.

Backups

Like any other system, you need to have a backup. Some hosting services offer these but the free ones generally require down time of your server, and some limit the number of backups you can have.

To solve it, I simply used git. I put the entire blog as a git repository in BitBucket, under a private repository of course since it contains all the content and configuration of the blog.

Everytime a do an upgrade to Ghost, I simply commit the change to the git repo and I'm done! I have a backup, and if I have an issue, I simply revert to the previous version, and investigate the issue in my local machine while the blog itself is still live.

Note that you need to shutdown the Ghost before you do that. If not, you'll get corrupted data in the ghost DB which won't unable you to bring it back up if you need to revert.

swap

After a while running Ghost, I found out that the server has a memory issue (I had problems connecting to it with SSH). The good folks of Digital Ocean helped me realize that I need either to add more RAM to the server or configure swap (aka virtual memory for you windows fans).

I found this great article which explains how to configure this in Ubuntu.

Utilities

After a while, I saw that many of the actions I do in order to maintain the blog are very repetitive. So I created several scripts to help me with these tasks.

These include:

  • Starting and stopping ghost (using forever as the runner)
  • Update the OS
  • Shutdown server
  • Upgrade Ghost: downloads the version, stops ghost, backs it up to BitBucket, upgrades ghost, back it up again, and starts it. (I also want to add a splash screen in nginx in the upgrade process which can take a couple of minutes). Note that this script deletes the content folder, so all of your customizations of the theme needs to be saved and restored from a different location.

You can find these scripts here. Feel free to use and change them.

Now that you have a working blog, its time to start writing, so get to work.

Yossi Shmueli

Keeping it green since 1995

comments powered by Disqus