It's been a long, long time coming. Or at least it seems that way.

This semester, Spring 2014, my last semester as an undergrad in ECE at UIUC, has been a busy one. I've been stretching myself in both directions, from understanding how computers are built from the ground up in ECE 411 to building website that are not only functional, but also beautiful in my Graphic Design class. It's been only a month or so since I got my Digital Ocean droplet up and running, but it feels like I've had it forever. I've struggled with even the simplest of things, but today I finally sat down, and did what I've been meaning to do for forever a little over a month: Install Ghost and start recording some of the things that I've been working on and struggling with.

So, naturally, the first thing that I want to write about is getting Ghost up and running.

Picking Ghost

The Ghost Logo

I have been looking at Ghost since it was just a Kickstarter Project, and I'm embarrassed to say that I didn't contribute back then. It has really grown into something great, even though it hasn't even hit version 1.0 yet. It checks all the boxes that a optimistic developer wants checked; it's open source, it's got developers who care, it supports Markdown (it's nice to write blog posts like I write Github README.md's and commits), and it's just really, really pretty right out of the box.

There weren't many alternatives that I considered. I wanted something that I could host myself, as a learning experience, and that basically narrowed my choices down to Ghost and Wordpress. The choice was a no-brainer.

Getting Ghost Working

This was harder.

My Setup

  • Digital Ocean VPS
  • Running Arch Linux
  • Apache doing a proxy pass to Node.js

Steps

0. Get your Server - I assume that you have your server, you can SSH into it, and you have root access.

1. Install Everything - Install apache and node with pacman -S apache nodejs.

1.5 Install Some Tools - Arch is notorious for not coming with anything. So, I had to install a few extra tools: pacman -S vim wget unzip.

2. Get Ghost - I chose to get the non-production version of Ghost (read:not the one on Github). I did this by doing wget http://ghost.org/zip/ghost-0.4.1.zip. Unfortunately, the Ghost folks don't have /latest download yet, so be sure that you're getting the latest version.

3. Start Ghost - I chose to run ghost from /ghost. If you agree that this is a sane choice, you can mkdir /ghost && mv ghost-0.4.1.zip /ghost && cd /ghost && unzip ghost-0.4.1.zip in one step.

4. Configure Ghost - Check out the Ghost Configuration Guide, specifically their section on Email Setup to do this part. The punchline is that you should get a Mailgun account, set your DNS up according to this guide, and be sure to set your URL: I'm using blog.kashevdalmia.com.

5. Start Ghost - From /ghost or wherever you're deciding to run Ghost from, run npm install --production. Adding the production flag ensures that you don't install the packages you'd need to develop Ghost, which would just take up space on your server. You can start Ghost after do this by running npm start, but don't do that yet.

5.5 Start Ghost Forever - The ideal set up, if you're sure that Ghost is what you want, is to have it run automatically on startup. To do this, install forever : npm install forever -g, then run NODE_ENV=production forever start index.js. You can subsequently start it using forever stop index.js, and see if you did this step right by running forever list.

6. Set Up Apache - Huge thanks to Steve Toye and his guide on this topic for his guide on doing this. The way these instructions differ from his is that we're using forever instead of writing our own service. Using forever is what the Ghost Docs recommend, and it's much simpler.

A common set up (and mine) is to have your main website at a URL like http://kashevdalmia.com and then have your blog set up at http://blog.kashevdalmia.com. You'd like to have your main website served by Apache, and you'd like to have your Ghost blog too, served by Node.js. Well, they can't both have port 80, so you have to tell Apache to proxy the traffic to http://blog.kashevdalmia.com to a different port (which if you left it as default in step 4, will be be 2368).

First, open /etc/httpd/conf/httpd.conf in vim or your favorite command line editor, find the linst that says #Include conf/extra/httpd-vhosts.conf, and uncomment it by removing the # from the beginning of the line. Then, open up /etc/httpd/conf/extra/httpd-vhosts.conf, and replace the contents of that file with something similar to the following (put your URLs and credentials instead of mine):

<VirtualHost *:80>
    ServerAdmin kashev.dalmia@gmail.com
    DocumentRoot "/srv/http"
    ServerName kashevdalmia.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin kashev.dalmia@gmail.com
    DocumentRoot "/ghost"
    ServerName blog.kashevdalmia.com
    ProxyPass / http://127.0.0.1:2368/
    ProxyPassReverse / http://127.0.0.1:2368/
    ProxyPreserveHost On
</VirtualHost>

Finally, restart Apache by running systemctl restart httpd. This will cause the new configurations to be used.

7. Blog - One of the reasons I wanted a blog, and frankly went through all this trouble to get it, is because of the Keys Left website. Based on your age and typing speed, it tells you how many key strokes you have left before you die. The idea is that you should make them count, and make the words you write accessible to all. Basically, blog about it. That's what you and I wanted Ghost for, so go forth and do it.

Thanks

I have to give credit where credit is due; I used a hodgepodge of different posts to get to where I got.