Upgrading self-hosted Ghost from v3 to v4

Upgrading my theme

Command to transfer the file to Skyleafdesign.com

scp ./valkyrie.zip my_host_:/home/my_user_/

I got this error after doing apt-get update followed by apt-get upgrade:

  • didn’t cause any problems

Commands to upgrade the theme

sudo chown -R ghost:ghost ./my_theme
sudo find ./my_theme -type d | sudo xargs chmod 755
sudo find ./my_theme -type d | sudo xargs chmod 644

ghost start gave the following error:

Command to fix file permissions

sudo find ./ ! -path "./versions/*" -type f -exec chmod 664 {} \;

Good to go after that:

Upgrading to Ghost 4.0

Reference: https://ghost.org/docs/update/

Command to upgrade Ghost

ghost update

Oh no! I need to upgrade Node to get Ghost:

Recommended version:

Commands to install Node

curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt-get install nodejs
  • the above Nodesource script will create a file in /etc/apt/sources.list.d/nodesource that should contain the version you specified

But there’s a compatibility issue, since my Ghost version is too old to work with the new NodeJS version:

You have to upgrade Node to 12 first, and then upgrade to Ghost V4, and then to Node 14 if you still want it.

After installing Node v14, apt-get wouldn’t downgrade it—the only choice was to sledge-hammer it and reinstall:

sudo apt-get remove nodejs
sudo apt-get install nodejs

Then you have to upgrade the command-line client!

Now npm is broken:

Reference: https://askubuntu.com/questions/1189230/what-is-the-location-of-node-modules

Command to delete all node modules

sudo rm -rf /usr/local/lib/node_modules/
sudo npm install -g npm

It couldn’t find the ghost command in my $PATH, so I had to kill the SSH connection, and then log back in:

Ghost won’t let you upgrade directly from v3 to v4; you need to upgrade the v3 version first, and then jump to v4 afterwards:

Staggered upgrade commands

ghost update v3
ghost start

… but it just hung here for a long time

  • persisted after a reboot

Attempting the upgrade anyway

Tying up loose ends

Ghost command still hangs

Fix here: https://forum.ghost.org/t/problems-starting-ghost-2-25-1-on-debian-9-9/7912/8

Modify the systemD unit to point to the new Node install:

Commands to edit the systemd service

sudo vim /etc/systemd/system/ghost_blog.service
sudo systemctl daemon-reload

SONIC BOOM YOU WIN!

Raphael Spencer

Raphael Spencer

Writing about polyglot software dev in the startup space. I break down the systems for success, and share tech tips I find along the way.
Green Bay, Wisconsin
.