How to Upgrade Ghost

How to Upgrade Ghost
Ghost blog admin panel

Updating the Ghost publishing platform when security patches are released is crucial to protect your site from getting hacked. Updating Ghost is easy to do and can be done by running a few simple commands. This guide will show you how to upgrade self-hosted installations of Ghost to the latest version.

Ensure you have a backup!

Ensure that you take a backup of the blog before you perform the upgrade. It's uncommon for something to go wrong, as the Ghost-CLI tool has been, in my experience, quite reliable.

Taking a backup is easy - simply go to the Ghost admin panel, click on settings, then Labs. Click the 'Export' button in the section for 'Export your content'.

taking a backup of your ghost blog as a json file

Connect to your host

Connect via ssh to the host and ensure that you have an account that can sudo, as you'll need to have escalated privileges to start and stop the Ghost process(es).

Update node if necessary

The Ghost developers will change the minimum node version supported as the application continues to be developed and improved. Updating node is easy to do, simply install nvm.

Instructions for installing nvm can be found here, or you can install it by running this bash script:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
installing nvm

Then once nvm is installed, reload your shell or run the following to put it in your path:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
reload your shell or run these commands

Then install the LTS version of node.

nvm install --lts
nvm use --lts
just use the latest lts version of node to keep ghost happy

Once that's done, continue with the installation.

Update Ghost-CLI

Ghost-CLI is a command-line tool that facilitates management of your Ghost blogs. When performing an upgrade, it's often necessary to update Ghost-CLI as well. This can be accomplished by running:

sudo npm install -g ghost-cli@latest

Once installed, your Ghost-CLI will be able to execute the upgrade without issue.

Run the Upgrade

Running the upgrade is easy. Simply run ghost update in the directory that holds your Ghost installation. If you don't know where this is, run ghost status and look at the 'Location' column. Navigate to that directory and run ghost update. You will need to enter your sudo password in order to stop and restart the process.

app@freshydrop-001:/var/www/freshyjmp-ghost$ ghost update
+ sudo systemctl is-active ghost_freshyjmp-com
✔ Checking system Node.js version - found v14.18.0
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking free space
✔ Checking for available migrations
✔ Checking for latest Ghost version
✔ Fetched release notes
✔ Downloading and updating Ghost to v4.16.0
+ sudo systemctl stop ghost_freshyjmp-com
✔ Stopping Ghost
✔ Linking latest Ghost and recording versions
+ sudo systemctl start ghost_freshyjmp-com
Warning: Ghost is running with node v12.19.0.
Your current node version is v14.18.0.
✔ Restarting Ghost
✔ Removing old Ghost versions
app@freshydrop-001:/var/www/freshyjmp-ghost$ ghost status

That's it, you're done!

Conclusion

Update Ghost when there's critical security issues. Not only does it make your installation more secure, but it reduces issues caused by major version changes if you're upgrading more frequently. Thankfully, the Ghost-CLI makes the job easy and painless.

Jon P

Jon P

I'm the author of these works. Technical professional and independent investor. Dabbler in everything. Good luck!