How to Upgrade Your Ghost Blog to the Latest Version

How to Upgrade Your Ghost Blog to the Latest Version

comments

The developers at Ghost release patch and minor version updates regularly. So after you install Ghost, you'll find yourself needing to upgrade your blog installation quite frequently.

To find out which version of Ghost you're using, log into your control panel from an account with administrative privileges. There's a drop-down menu on the top left of the screen. On the menu, click About Ghost.

ghost-admin-panel-about-ghost

Alternatively you can also reach the about page by directly navigating to: www.yourwebsite.com/ghost/about/

ghost-admin-panel-version-information

You'll be notified of new releases at the top of your admin panel.

ghost-admin-panel-upgrade-notification

If you're using Ghost-CLI, all you'll need to do is run the ghost update command. For manual installations, I've outlined the steps you need to take in this guide.

I've installed Ghost to /var/www/ericmathison.com/blog - you'll need to update this to your own location.

Backup your data

This should go without saying. But backup your website's data.

cd /var/www/ericmathison.com
zip -rq ~/blog.zip ./blog

Download the latest version of Ghost

Download the latest version of Ghost from their website.

curl -kLo ~/ghost-latest.zip https://ghost.org/zip/ghost-latest.zip

Unzip the latest version to a new directory

unzip -q ~/ghost-latest.zip -d ~/ghost-latest

Delete the old files

If you skip this step by uploading the new files and overwriting the old ones, you might be keeping files that are no longer used anymore.

So, it's best practice to first delete the /core/ directory, package.json and all of the .js and .md files.

Make sure NOT to delete your config file.

cd /var/www/ericmathison.com/blog/
rm -rf core/ *.js *.md package.json

If you haven't modified the default Casper theme files, you can delete this directory, too.

rm -rf content/themes/casper

Copy the New Files

Make sure you're in the blog's parent directory with pwd.

[email protected]:/var/www/ericmathison.com/blog$ pwd
/var/www/ericmathison.com/blog

Copy the following new files over.

cp -R ~/ghost-latest/core/ .
cp ~/ghost-latest/*.md .
cp ~/ghost-latest/*.js .
cp ~/ghost-latest/*.json .

If you're upgrading the default Casper theme, copy the new files over at this time.

cp -R ~/ghost-latest/blog/content/themes/casper content/themes/casper/

Update the Dependencies

Switch to your Ghost blog's parent directory and issue the following command. It's normal for this command to take up to a couple of minutes to perform.

cd /var/www/ericmathison.com/blog
sudo npm install --production

Migrate the Database

sudo NODE_ENV=production knex-migrator migrate

Update the File Permissions

You should be running Ghost under a non-privileged user. I run my Ghost service under an account named ghost. Make sure the proper permissions are set.

sudo chown -R ghost:www-data /var/www/ericmathison.com/blog

Restart Ghost

If everything went as planned, your Ghost blog will now be running the latest version available.

sudo service ghost restart

You can confirm the version is the latest by going to the about page in the admin panel.

ghost-admin-panel-upgraded-version-information

Troubleshooting

Delete and reinstall the dependencies.

sudo rm -rf node_modules
sudo npm cache clean
sudo npm install --production

Default File Permissions

You'll want to make sure that all of your directories are set to 775 and all of the files are set to 664.

sudo find /var/www/ericmathison.com/blog -type d -exec chmod 775 {} \;
sudo find /var/www/ericmathison.com/blog -type f -exec chmod 664 {} \;