So I finally got around to starting my blog, and decided to use the Ghost blogging platform. Here's the process that I went through to get it up and running on an Ubuntu instance on Amazon EC2, but it should work for any modern Ubuntu (and many other Unixes).

An aside...
It's interesting that I as I was doing this I thought it was a pretty straightforward. But once I then started writing it up here I realise it is actually complicated. There's a lot of moving parts and knowledge that's required to do this, so I hope you find this useful.

Amazing how the knowledge we have becomes second nature and we forget just how much there is to learn.

There are simpler ways to do this, but this is how I recommend you do it for various reasons. This way gets you set up with source code control using Git and your own theme so you can hack on your blog (who doesn't want to hack on their blog!). What's more you can easily pull updates as Ghost is updated over time, and also allows you to submit pull requests to Ghost if you've got something to contribute.

This whole process is done using the console, so fire up a terminal or translate into your tools of choice for Windows.


A quick note about Ruby: Hopefully installing Ruby doesn't give you trouble, IMHO it shouldn't be a prerequisite of Ghost, and I've created an issue to make installing this not necessary.

Get Ghost

This one's pretty simple, just change directory to somewhere sensible and run the following commands:

git clone "" $dirName  
cd $dirName  
git submodule update --init  
npm install -g grunt-cli  
npm install  
bundle install  
grunt init  
npm start  

If all goes well, you can now go to http://localhost:2368/ and see your wonderful new blog in all its un-styled glory. Go to http://localhost:2368/ghost/ to see the backend and create a new post (just enter your details to create an Administrator login).

Pretty cool huh? Okay, now time to make it purty...

Get Styling

No go and find yourself a theme that you like and drop it into content/themes.

Here's where I went looking for themes:

You'll need to restart Ghost before it'll allow you to select newly install themes, so go back to your console and press Ctrl-C to terminal Ghost and then run npm start to start it up again. Now go to http://localhost:2368/ghost/settings/general/ and select one of the themes that you added in the Theme section of the form.

I chose Ellie (demo), although close second was Ghostwriter (demo).

Now add your theme to the repo, or see below for bonus points:

git add -f "content/themes/{{theme directory}}"
git commit -m"Added theme"

For bonus nerdy points...

Because Ellie was available on Github, and because I like to keep things neat and tidy I added Ellie as a git submodule and then created my own copy (I could have used a fork but, uh I didn't) which I added to my repo. This allows me to pull updates to Ellie in the future if I like, and copy them over to my theme.

This process was:

git submodule add -f "" "content/themes/ellie"
mkdir "content/themes/$dirName"
cp -r "content/themes/ellie/*" "content/themes/$dirName"
git add -f "content/themes/$dirName"
git commit -m"Added themes"

Set up Your Configuration

Now you need to tell Ghost where your blog lives, so open up config.js in your editor of choice.

If you're on EC2 then you can use the hostname that they give you, but you'll probably want to set up a domain name rather than using this ugly hostname :)

Now add these changes to your Git repo:

git add -f "config.js"
git commit -m"Updated config"

Push Your Changes

Okay now we need to push our changes to a Git repository. I recommend you create one on Github or Bitbucket (Bitbucket will let you keep your code private if that's your thing). This post assumes Github, but the same applies to Bitbucket.

When you complete this process they will provide you with a URL that you can use to push your changes:

Github example

You'll need to go through the process of setting up your SSH keys so that you don't need to enter your username and password every time, and so that you can access your repo from the server later on.

Now, copy that URL and:

git remote rename origin upstream
git remote add origin "{{the URL you copied before}}"
git push origin master --set-upstream

Congratulations, you've just pushed a Git repository!

Upstart Config

We're going to use Upstart to make sure that our server starts when the instance boots up. Create a new file upstart.conf in your text editor of choice and copy the code from this Gist into it.

n.b. You may need to change my-blog and /data/my-blog to the whatever you used for $dirName above.

Now add this to Git using:

git add upstart.conf
git commit -m"Added upstart.conf"
git push origin master

Now, to the Cloud!

Okay, so if you don't already have an EC2 instance then you create one using these instructions. Then you should SSH to your instance so we can set up Ghost.

You'll want to use SSH Agent Forwarding so that you can access your Git repo from the server. You can do this by adding -A to your SSH command, but I recommend adding the following entry in your ~/.ssh/config file:

Host {{your domain name}}
    Hostname {{EC2 domain name e.g.}}
    User ubuntu
    IdentityFile ~/.ssh/{{path to your Amazon .pem file}}
    ForwardAgent yes

This allows you to SSH to {{your domain name}} and to then authenticate over SSH as though you're on your local machine:

ssh {{your domain name}}

(Answer yes to the warning about the fingerprint.)

Deploy the Amphibious Squadron

Okay, so you've SSHed to your instance. Now you'll need a few packages installed first:

sudo apt-get update
sudo apt-get install git nodejs npm ruby -y
sudo ln -s nodejs /usr/bin/node
sudo npm install npm grunt-cli forever -g
sudo gem install bundler

Ubuntu 12 users see this Gist for slightly different install instructions sent in by nifl.

If you want to run multiple sites on this instance then you'll need to set up Nginx or some other reverse proxy to listen on port 80 and then pass the requests to the appropriate process for each website. But that's outside the scope of this post, so I'm assuming that this is the only site you're running on this instance.

Now, let's clone your Ghost repo on the instance. Feel free to change $dirName to whatever you want.

sudo mkdir -p $dirName
sudo chown ubuntu $dirName
cd $dirName
git clone "{{the repository URL you copied from Github before}}" .

(Answer yes to the warning about the fingerprint, then...)

git submodule update --init
sudo npm install
grunt init prod
sudo NODE_ENV="production" npm start

If everything's worked then you should be able to go to http://{{your domain name}}/ghost/settings/general/ and select your theme, and your shiny new blog will be online at http://{{your domain name}}/.

Last Step

Copy the upstart.conf file into /etc/init so that your blog starts when the instance boots up:

cp upstart.conf "/etc/init/my-blog.conf"

Make sure you check that it does start by rebooting the instance using shutdown -r now.

Where to From Here?

Now you've got your very own blog, and it's yours to do with as you please!

You can make some changes to your theme, add them to Git (using git add, git commit and git push). Then when you're happy with them, SSH to your server, cd /data/my-blog and run run git pull to update your blog.

One final note: your server isn't set up to send email yet, but that's a topic for yourself to work out - I'm out of time here :)