Upgrading your Ghost blog

For official upgrade document, follow this link. This post still has a purpose, because the official documentation does not talk about what to do if you have customized certain aspects of your blog. For example, if you click this link Services, you will be taken to our services page in the same window. However, if you click on any external link like Digital Ocean it will open the link in a new tab!

If you are new to Ghost platform, you can read our other posts on Ghost here.

NOTE: DO NOT REPEAT THE FOLLOWING STEPS IN PRODUCTION DIRECTLY. FAMILIARIZE YOURSELF WITH THE CONCEPT AND START WITH YOUR STAGING OR DEVELOPMENT ENVIRONMENT

Step 1: Download Ghost

Start by downloading the latest version of Ghost on your server.

curl -LOk https://ghost.org/zip/ghost-latest.zip  

Step 2: Unzip Archive

The downloaded file is a ZIP file and you need to unzip it using the following command.

unzip ghost-latest.zip -d ghost-temp  

Step 3: Install

Navigate to the directory and install Ghost by using the following commands...

cd ghost-temp  
npm install --production  

Step 4: Check Installation

To confirm that the installation is successful, run npm start

 ghost@0.11.9 start /home/ec2-user/ghost-temp
> node index

WARNING: Ghost is attempting to use a direct method to send email.  
It is recommended that you explicitly configure an email service.  
Help and documentation can be found at http://support.ghost.org/mail.

Migrations: Creating tables...  
Migrations: Creating table: posts  
Migrations: Creating table: users  
Migrations: Creating table: roles  
Migrations: Creating table: roles_users  
Migrations: Creating table: permissions  
Migrations: Creating table: permissions_users  
Migrations: Creating table: permissions_roles  
Migrations: Creating table: permissions_apps  
Migrations: Creating table: settings  
Migrations: Creating table: tags  
Migrations: Creating table: posts_tags  
Migrations: Creating table: apps  
Migrations: Creating table: app_settings  
Migrations: Creating table: app_fields  
Migrations: Creating table: clients  
Migrations: Creating table: client_trusted_domains  
Migrations: Creating table: accesstokens  
Migrations: Creating table: refreshtokens  
Migrations: Creating table: subscribers  
Migrations: Running fixture populations  
Migrations: Creating owner

ERROR: (EADDRINUSE) Cannot start Ghost.  
 Port 2368 is already in use by another program. 
 Is another Ghost instance already running? 

Notice the last line. Even though it is erroring out due to Port 2368, I would assume that if I stop my current Ghost site, the current command will work. However, I would not do that because the data is not migrated yet. Sometimes a package or two fails during npm install and it is a good time fix that before proceeding ahead.

Step 5: Take Backup

Ensure that you take a backup before proceeding ahead and navigate to the directory.

cp -R website website-backup  
cd website  

NOTE: THE FOLLOWING COMMANDS REQUIRES DOWNTIME SO CHOOSE A SUITABLE TIME

#Remove the core directory
rm -rf core  
#Copy the core files from fresh installation
cd ../ghost-temp/  
cp -R core ~/website  
cp index.js *.json ~/website  
#Change to your website and install dependencies
cd ~/website  
npm install --production  

Step 6: Re-Apply your code changes

Now, reapply your code changes. If you maintain the website using Git, it is a piece of cake. You just need to document and remember the files where you have made changes. Let's say you have made changes to a specific file and you want to reapply those changes. You can view the difference and reapply your code changes appropriately. If you think your code is "additive" in nature and no other part has been modified in the latest build of Ghost, you can simply type the following command to revert the changes using:

git checkout core/server/routes/frontend.js  

NOTE: THE FILES WILL BE DIFFERENT IN YOUR CASE. SUIT YOURSELF!

Step 7: Restart and Clean Up

If you use PM2 to manage your Node application, PM2 restart app-name will restart the application and you should be good to go.

To clean up, just delete the following and move your backup directory to an appropriate folder:

rm ghost-latest.zip  
rm -rf ghost-temp/  
mv website-backup backups/yyyy-mm-dd/  

And you are done! Welcome to the shiny new version of Ghost :)

What next?

Not much! Say hi, leave a comment or Subscribe now to stay updated through our monthly newsletter. Also, check out our services or contact us at contact@attosol.com for your software and consultancy requirements.

Rahul Soni

⌘⌘ Entrepreneur. Author. Geek. ⌘⌘

Kolkata, India

Subscribe to Attosol Technologies

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!