Let's start a blog with Ghost

Ghost is a very interesting blogging platform. Granted it is still in its infancy, the latest version (0.4.2) is simple and stable enough for our needs. Here's what we have with Ghost:

  1. An intuitive markdown editor
  2. Drafts, static pages and tags
  3. Images upload
  4. An evergrowing marketplace of free/paid themes.

And really, that's pretty much all we need. What's coming in future releases (multiple users, dashboard widgets, etc...) will be sugar on top.

If you don't really want the hassle of installing Ghost, there's already a couple of webhosting that offer support for the blogging platform installation, among them there's Digital Ocean, OpenShift and of course you can start one on the official website Ghost.org.

For our blog, we want to clone the repository from Github. This will allow us to tinker a bit with it and not overwrite our changes on the next update. We're already going to add a little fix to localize the dates, more on that later.

In this tutorial, I'm installing Ghost on Ubuntu Server 12.04.4 LTS, and for our webserver, we'll use Nginx.

Install node.js

So let's fire up our terminal and start this thing. Let's install node.js first. For this we'd like a recent version so let's look up an available PPA.

Let's first make sure that we can add a repository:

sudo apt-get update  
sudo apt-get install python-software-properties  

Then add the ppa and update:

sudo add-apt-repository -y ppa:chris-lea/node.js  
sudo apt-get update  

Now let's install node! Node comes with an awesome package manager called npm, we'll install a wonderful tool called Grunt with it.

sudo apt-get install nodejs  
npm install -g grunt-cli  

Install Ghost

Let's start by cloning the repository:

git clone --recursive -b stable git://github.com/tryGhost/Ghost my-blog  

Here we ask git to checkout the stable branch. You can stay on the master branch if you want, but it is highly discouraged if you're publishing it to production. Change my-blog to whatever you'd like. For what comes next, make sure that you're not logged in as root, because the installation of bower depencencies will fail.

cd my-blog  
npm install  
grunt init & grunt prod  

Now open the file config.js file and look for this information:

    production: {
        url: 'http://my-ghost-blog.com',
        mail: {},
        ...
    },

You can change http://my-ghost-blog.com to your website address. Also you might want to setup an email service, there's an example in the development section.

Let's setup nginx

sudo apt-get install nginx  
sudo nano /etc/nginx/sites-available/ghost.conf  

And add this configuration :

server {  
    listen 80;
    server_name your-website.com;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}

Now let's enable our website and restart nginx:

sudo ln -s /etc/nginx/sites-available/ghost.conf /etc/nginx/sites-enabled/ghost.conf  
sudo service nginx restart

You can now look if your blog is working with:

NODE_ENV=production npm start  

If everything went ok, you should now be able to see your blog on http://your-website.com/, head up to /ghost to sign up for the admin area.

Install forever

But wait, that's not all! We want our blog to run forever, so we're going to start our site forever with a background process manager called, you guessed it, forever. So let's take our blog down for now, hit ctrl+C.

sudo npm install forever -g  
NODE_ENV=production forever start index.js  

If your application stops for whatever reason, forever will reboot it, wonderful! But if you'd like more control over your process, I encourage you to look the supervisord installation.

Now for a bonus, let's localize our dates!

Open up core/server/helpers/index.js, and add this after the variables assignment:

# Localized dates
moment.lang('fr');  

And put wathever language you'd prefer.

Let's start blogging!