How to Auto-Update Ghost on Digital Ocean: A Beginner-Friendly Guide

In this guide I'll show you how to auto-update your self-hosted Ghost Blog on Digital Ocean, even if you are a complete beginner that never used the terminal before.

Picture of the terminal window, and the text "ghost update... automatically!"

When trying to self-host Ghost on Digial Ocean, one thing that wasn't clear to me was how to keep it updated.

Installing updates are important to keep things secure and up-to-date, but having never used the terminal before - I had no idea how.

What I really wanted was a way to make my Ghost blog automatically update itself like my managed WordPress servers do.

Turns out, there's a super simple way to make that happen.

Here are exact the steps I took:

Part 1: Setting Up Automatic Updates for Ubuntu

The first part is making sure the Digital Ocean server auto-updates, so that any security vulnerabilities are patched up while we sleep.

1.1 Install Necessary Packages

Open your terminal and run the following command to install the necessary packages:

sudo apt update
sudo apt install unattended-upgrades update-notifier-common

This is going to update the server and all the apps.

I just clicked yes and enter all the way through to keep things defualt.

1.2 Enable Automatic Upgrades

Next, set automatic upgrades to be executed on specific days.

You do this by copy/pasting this line to edit the configuration file:

sudo nano /etc/apt/apt.conf.d/20auto-upgrades

Ensure it contains the following lines to enable daily updates and automatic cleanups every week:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

To save the file, press Ctrl+O, then press Enter to confirm.

1.3 Setting Up Email Notifications and Automatic Reboot (Optional)

If you want to receive an email notification if an update fails somehow, find and uncomment the line:

//Unattended-Upgrade::Mail "[email protected]";

"Uncommenting" something just means removing the // in front so it looks like this:

Unattended-Upgrade::Mail "[email protected]";

Replace "[email protected]" with your actual email address (doh!).

To enable automatic reboot after security updates are installed, find and uncomment this line:

//Unattended-Upgrade::Automatic-Reboot "false";

And change the "false" value to "true". You can also set a specific time for the automatic reboot by uncommenting and modifying this line:

// Unattended-Upgrade::Automatic-Reboot-Time "04:00";

To save the file, press Ctrl+O, then press Enter to confirm.

Then exit by pressing Ctrl+X.

Part 2: Setting Up Automatic Updates for Ghost

Ok, that's the server part done.

Now we're going to create a script to automatically update Ghost. (by 'creating' i mean copy/pasting)

We do this using something called cron jobs, which tells the server robots to execute things without you.

"Hey robots! At this time, go do this ghost update!".

In our case, the cron job will execute the command ghost update for us once a week to keep things up-to date.

Let's get staretd.

2.1 Create a Script for Updating Ghost

First we'll create a script named in the home directory of your Ghost manager user (ghost-mgr), and open it in the editor:

nano /home/ghost-mgr/

Now add the following lines to the script:


cd /var/www/ghost
ghost update >> /home/ghost-mgr/ghost_update.log 2>&1

This will the robot to go to the /var/www/ghost folder, execute ghost update, and update the ghost log after. Simple!

As before, save the file, press Ctrl+O, then press Enter to confirm.

Once saved, exit using Ctrl+X.

2.2 Make the Script Executable

To make the script 'executable', use this command:

chmod +x /home/ghost-mgr/

2.3 Set Up a Cron Job to Run the Script

Now we'll tell the robot when to execute the script we just made.

Open the crontab file to create a new cron job:

crontab -e

Add a line to the crontab file to run the script every Sunday at 3 am:

0 3 * * 0 /home/ghost-mgr/

"0 3 * * 0" represents minutes, hours, days, months, and weekdays in that order. Here, it translates to 0 minutes past 3 AM, on any day (), of any month (), but only on Sundays (day 0 of the week -_-)

To save the file, press Ctrl+O, then press Enter to confirm. To exit nano, press Ctrl+X.

2.4 Verify the Setup

After setting up the cron job, you can check that it works by opening the ghost_update.log file after the cron job has run next monday:

cat /home/ghost-mgr/ghost_update.log


You've now set up automatic updates for both your Ubuntu server and your Ghost blog on DigitalOcean.

The Digital Ocean droplet will auto-update daily, and ghost will auto-update once a week on sundays.

This simpe setup should help to keep your system and Ghost blog secure and up-to-date with the latest features and security patches.

Well done!

Resources I found helpful when learning how to auto-update ghost:

1. KyleUnboxed - How to Update Ghost on Digital Ocean
2. LinuxOpsys - How to Enable Automatic Updates on Ubuntu
3. DigitalOcean - How To Use Cron to Automate Tasks