Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Upgrade ghost blog on AWS ec2 server

Upgrade ghost on an ec2 host

The ghost version changelog: https://gist.github.com/kirrg001

Export content from https://blog.example.com/ghost/#/settings/labs, just in case. I'm using mysql on the backend and haven't needed this yet, but, it's nice to have a data backup regardless.

Upgrade to the latest npm, ghost-cli, and knex-migrator:

npm i -g npm
npm i -g ghost-cli
npm i -g knex-migrator

Give group "www" sudo access (I run ghost as user.group: "www.www").

sudo visudo

Stop the ghost service:

sudo service ghost stop

Become www and save a copy of the current configuration:

sudo su - www
cd /usr/share/nginx/node/ghost
rm previous
cp -P current previous

Upgrade should work, mostly, failing at "restart":

ghost upgrade

Clean up and add s3 storage back in and various configuration bits:

cd current
npm install ghost-storage-adapter-s3
npm install
cp ../../previous/config.production.json .

Update db (This step may not be required anymore. Will confirm next upgrade.)

knex-migrator init

Copy over my theme edits (for the qr-code/google search/...)

rsync -avP ../../previous/content/themes/keith/ ./content/themes/keith/

Copy over the s3 bits (maybe that should be an npm update?)

mkdir -p ./content/adapters/storage/s3/
rsync -avP ../../previous/content/adapters/storage/s3/ ./content/adapters/storage/s3/

Clean up permissions:

sudo chown -R www.www /usr/share/nginx/node/ghost

Test:

NODE_ENV="production" npm start

Go to https://blog.example.com/ and see if it looks ok.

If it does, ^C npm

exit
sudo service ghost start

Reload https://blog.example.com/ again to double check.

Comment out group www sudo access:

sudo visudo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment