Updating Ghost From The Linux Command Line

I've been running Ghost as my blog engine for some time and I find it's a wonderful experience. However, updating the engine itself still leaves a lot to be desired. I've had mixed results updating the necessary files via FTP, only having it work once the first time I updated it. Ever since, it's borked my install (thank goodness for backups!).

Luckily, there is a method for command line junkies like myself who want to update their Ghost blog but are afraid of ruining their installation with the conventional FTP updating method.

Before you do anything on your server, it's best to do a few things. First, back up your current installation. This is easily done quickly and safely via FTP with Transmit or Filezilla. Once you've made a copy of your installation, you will want to stop the Ghost from running on your Linux box. Since Ghost runs as a native node.js app and not something more dynamic like PHP in Wordpress, it's never a good idea to update it while running. There are several ways to do this, but if you've turned Ghost into a service on Ubuntu like I have, sudo and enter:

service ghost stop  

Please note that stopping Ghost from running is not a requirement, but I do recommend it. However, forgetting to stop it before updating isn't as catastrophic as flushing your car's radiator while it's running.

Next, you'll need to download core Ghost to your server. Since I do mostly everything as sudo, for things like this, I dump the download to my /root directory as follows:

cd /root  
wget http://ghost.org/zip/ghost-latest.zip  

The next step is to delete the /core from within the directory you have Ghost residing. For me, that's /var/www/ghost.

cd /var/www/ghost/  
rm -r core  

Once this is done, you can unzip your downloaded Ghost version.

unzip -uo ghost-latest.zip -d path-to-your-ghost-install  

Every time you update your core Ghost installation, you must grab the new dependancies for node.js by running npm install --production and watch the magic happen.

If you previously stopped the Ghost service from running, fire it up with service ghost start. If not, ... restart will work. If all went well you should now be running the latest version of Ghost.

A Word About Versioning

It's important to note that when updating your Ghost installation from a significantly older version, say v0.3.3, you should not skip over major releases numbers. For example, when upgrading from v0.3.3, it's recommended to use the following upgrade path:

0.3.3 -> 0.4.0 -> 0.5.0 -> 0.5.8

The reason for this is that older versions of Ghost were not as frequently updated as they are now. Major revisions of the Ghost core were done sometimes several months apart and dependencies may have changed between major revisions of the software. Skipping major version numbers - going from 0.3.3 direct to 0.5.0 - can cause your installation to die a horrible and painful death. There is no substitute for a good backup.

Happy updating.