2 min read

Upgrading to Ghost v6 on Ubuntu

I just upgraded my Ghost install to v6 on Ubuntu, and it took some problem-solving. I tried upgrading my Ghost install from v5 to v6, but my Node version was too old. I needed to install nvm under the ghost user. I did this a "bad but official" way:

# First, create the Ghost user's missing home directory
sudo mkdir /home/ghost
sudo chown ghost /home/ghost
sudo chgrp ghost /home/ghost

# Then act as that user to install nvm
sudo su ghost
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash

I then installed the Node version I wanted (v22, which is I think the latest stable version that also supports Ghost v5):

# sudo su ghost  # still acting as ghost user
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
nvm install 22

I then created a wrapper script /home/ghost/run_node.sh:

#!/usr/bin/env bash
DESIRED_VERSION="${1:?}"
shift 1

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

nvm use "${DESIRED_VERSION:?}"
node "$@"

Then I made sure this was executable by the ghost user:

sudo chown ghost /home/ghost/run_node.sh
sudo chgrp ghost /home/ghost/run_node.sh
sudo chmod ug+x /home/ghost/run_node.sh

Then I edited the Ghost systemd unit file /etc/systemd/system/multi-user.target.wants/ghost_${my_website}.service (replacing ${my_website} with the appropriate text) to change the ExecStart line:

# commented out: the old command
# ExecStart=/usr/bin/node /usr/bin/ghost run
ExecStart=/home/ghost/run_node.sh 22 /usr/bin/ghost run

Then I restarted and made sure that this works correctly.

Finally, I installed nvm and Node v22 on my user, installed ghost-cli there, made backup, and ran the update to v6. The rest of this process went smoothly. After upgrading, I find that ghost doctor is unhappy that it can't figure out the node version being used by looking at ExecStart, but the blog runs fine. Also, my theme might be slightly out of date — I saw an error and two warnings to the effect that my new theme doesn't support all page features — but it seems to be working about as well as it used to do, and that's good enough for me right now.

Unfortunately, I haven't been able to get the new ActivityPub features working yet despite updating my nginx config as per the update instructions. That's an issue for another day.