How to Update Ghost on DigitalOcean Managed by Serverpilot

How to Update Ghost on DigitalOcean Managed by Serverpilot

UPDATE¬† 4/2/19: While the information below may still be useful to some, I’ve since moved away from ServerPilot and now use RunCloud. You can read my post as to why I switched here.

UPDATE 5/3/18: The following information is no longer valid. Ghost has since introduced a command line tool for installing and updating their software. I will, however, leave this information here for historical purposes.

While I’m in love with Ghost, one thing I definitely believe could be improved is the upgrade process. Because of how nice Ghost’s interface is, one would think they would have auto-update capabilities out-of-the-box (which I’m sure will come eventually), but currently it’s a very manual process.

I’ve compiled a list of commands that should automate the process slightly. Though I could turn this into a bash script, it’s just as easy to copy and paste these commands into a terminal window.

Note: If you don’t already have a good web host, I highly recommend BlueHost. I’ve partnered with them to get you an introductory rate of $3.95/month.

Before running these, make sure you snapshot your DigitalOcean droplet. I’m not responsible if this breaks anything.

Make sure you’re running as root.

sudo su

Then, cd to your app’s root directory.

cd /srv/users/serverpilot/apps/<APPNAME>

The following commands may need to be modified slightly, depending on how you’re getting your ghost instance to run automatically. I personally use pm2, but I know of others who are using forever. Also, my pm2 instance is named ghost. If yours differs, you will need to alter that as well.

Keep in mind, this may take 3-4 minutes to run through completely. If you have a lot of traffic, you may need to do this during a maintenance window.

pm2 stop ghost
cp -r public public_backup
unzip -o -d public
cd public 
rm -rf content
cd ..
cp public_backup/config.js public
cp public_backup/.htaccess public
cp -r public_backup/content public
cd public
npm install --production
pm2 start ghost
cd ..
chown -R serverpilot:serverpilot public

And then, when you’re absolutely POSITIVE that everything is back up and running like it’s supposed to be, delete the backup:

rm -rf public_backup

Leave a Reply

Your email address will not be published. Required fields are marked *