Upgrading Self-Installed Ghost on Linux Server (CentOS 6)

Context

These are instructions for how to upgrade a self-installed ghost blog on a linux server (These instructions are used on CentOS 6). It assumes you have installed ghost yourself. This was used to upgrade ghost from 0.4 to 0.5. In this case the old ghost directory was located at /var/www/ghost.

First Step Make a backup

Check here for how to make a backup

Instructions Overview

[ahmed@amayem ~]$ mkdir temp
[ahmed@amayem ~]$ cd temp
[ahmed@amayem temp]$ wget http://ghost.org/zip/ghost-latest.zip
[ahmed@amayem temp]$ sudo rm -rf /var/www/ghost/core/
[ahmed@amayem temp]$ sudo unzip -uo ghost-latest.zip -d /var/www/ghost/
[ahmed@amayem temp]$ cd ..
[ahmed@amayem ~]$ rm -rf temp/
[ahmed@amayem ~]$ cd /var/www/ghost/
[ahmed@amayem ghost]$ sudo npm install --production
[ahmed@amayem ghost]$ sudo supervisorctl restart ghost
ghost: stopped
ghost: started

An explanation

We first made a temporary directory and moved into it, then we downloaded the latest ghost release. Then we deleted the core directory in the already installed ghost, as instructed by the ghost support upgrade documents. Then we unzipped the donwloaded zip file into the ghost directory with the options u and o. Let’s tale a look at the man page of unzip to understand:

-u      update existing files and create new ones if needed. This option performs the same function as the -f option, extracting (with query) files that are newer than those with the same name on disk, and in addition it extracts those files that do not already exist on disk. See -f above for information on setting the timezone properly.

 -o     overwrite existing files without prompting. This is a dangerous option, so use it with care. (It is often used with -f, however, and is the only way to overwrite directory EAs under OS/2.)

So what we are doing is unzipping the file such that it updates any files that have been changed, leave the files that are unchanged and put in the files that are in the new release. Notice that it doesn’t delete the files in the old ghost directory that are not in the new release. This means that the config.js file is safe and won’t be deleted.

Afterwards we deleted the temp directory that we made. Then we moved to the ghost directory where we could udate any dependencies using sudo npm install --production. We need to be in that directory because we need the package.json file in there to indicate the dependencies.

Finally we restart ghost. I installed supervisor and was running ghost using it so I used the supervisorctl commands.

References

  1. ghost support upgrade documents

Ahmed Amayem has written 90 articles

A Web Application Developer Entrepreneur.