Ghost: Digital Ocean Edition

Learn how to update your Ghost installation on Digital Ocean, and how to fix some errors such as Yarn.

Ghost: Digital Ocean Edition

Hello again, as you may or may not know this blog is powered by Ghost. It's fantastic and easy to use, but if you want the devs to host it for you it's quite pricey. Coming in at 36 bucks a month if you do month to month. I don't know about you but I don't pull in a ton of viewers to pay for that. That's why using another company to host may be better. Digital Ocean has come cheap packages you can use.

If you go down the self hosted route and you don't know linux never fear! Digital Ocean has quiet a few resources for you to get everything up and running. I'm going to focus on how to keep your website up to date. You can use their website and use a console to access your site, but I prefer to use an SSH client. If you're using SSH you should be using keys to verify your identity. That's not covered in this article!

Termius is a multi-platform SSH client. It does a few other things too, but I'll just be using the free version and the ssh portion. You can save in your credentials in the app so you don't have to remember them, but I highly do not recommend this! I only save in the IP address of my server. You can find the public IP by going to the dashboard on digital ocean.

Once you get into your server there are a few easy commands that you can do to get all your updates running. I highly recommend keeping your server up to date. It will keep it secure, and reduce your risk of being hacked.

First lets get that operating system updated. I recommend running this commands in order. Sometimes you may need to reboot or the website may be down for these commands. You will want to do them at off hours. Anything after # on the same line is a commend. Do not type the # or anything after it on the line.

sudo apt-get update        # Fetches the list of available updates
sudo apt-get upgrade       # Strictly upgrades the current packages
sudo apt-get dist-upgrade  # Installs updates (new ones)

Sudo apt0-get dist-upgrade can take a decent amount of time so you will want to do it later in the night unless you don't mind the downtime.

Once you have your OS updated the next step is going to be getting ghost up to date. Just like your OS keeping this up to date will increase your security, and the features available to you.

sudo  -i -u  ghost-mgr # change to the user ghost-mgr
cd /var/www/ghost # Changes your directory to the ghost directory
npm install -g ghost-cli@latest # Updates the CLI to latest version
ghost update # Updates the ghost application

Going through those steps should get your website up to date. Read through the lines and look for any errors. It should be a pretty simple process for you. The biggest issue I have run into is that Ghost uses something called Yarn. The developer behind Yarn follows security practices and he changes his keys every 1-2 years. When this happens you need to update yours. You'll see when you run a sudo apt-get update an error that complains about Yarn keys. Below should update this for you.

wget -O yarnpkg.gpg.pub https://dl.yarnpkg.com/debian/pubkey.gpg #Get the Key
gpg yarnpkg.gpg.pub #just check the expired date of the key
sudo apt-key add yarnpkg.gpg.pub # Adds the Key

With all that said your application should be up to date! If you get stuck feel free to reach out or even reach out to Digital Ocean's support. I've had great luck with them. Thanks.