How to upgrade Ghost v2 to v4?
Hello guys,
Today I would like to give you an instruction to upgrade Ghost from v2 to v4. Because version 2 is not stable and will not support by the author at the end of this year. So that's why I need to upgrade it.
First of all, you should back up your server data (create a new droplet on the DigitalOcean), backup your database, backup ghost configuration and ghost theme zip file (export data/theme zip in administrator page).In the next step, you should check your MySQL version. If it is v8 then you can ignore step 1.
-
Upgrade MySQL from 5.7 to 8 (https://tastethelinux.com/2020/09/14/upgrade-mysql-server-from-5-7-to-8-ubuntu-18-04/)
-
Create a new database
- mysql -uroot -p
- CREATE DATABASE
<your-database-name>
; - GRANT ALL PRIVILEGES ON
<your-database-name>
.* TO '<your-database-username>
'@'localhost' IDENTIFIED BY '<your-database-user-password>
';
- Upgrade nodejs from 8 to 10 (ghost 2@latest works on it)
- curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash
- sudo apt-get install -y nodejs
- **
- Upgrade ghost-cli to the latest version
- sudo npm install -g ghost-cli@latest
- Update Ghost to v2@latest
- ghost update v2
- Upgrade nodejs from 10 to 14
- curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash
- sudo apt-get install -y nodejs
- **
- Upgrade ghost-cli to the latest version again
- sudo npm install -g ghost-cli@latest
- Upgrade ghost from v2@lastest to v4@latest
- ghost update --force
- Configure your database from old to a new one to ignore conflicts
- cd
<ghost-project-dir>
- ghost setup
- You will be asked to fill in data, just focus on database fields.
- Start the ghost.
-
Check the blog overview on the browser, now you will see new posts, new designs from Ghost.
-
You should fix theme issues that come from theme v2 to v4.
- Upload the theme zip file to the page https://gscan.ghost.org/
- Check issues, fix it
- Build zip again (check the package.json commands)
- Install theme
- Go to https://your-domain.com/ghost/#/settings/theme
- Choose the latest theme
Upload it
Additional steps after fetched the Debian.
- Run
sudo apt-get install -y nodejs
to install Node.js 10.x and npm - You may also need development tools to build native addons:
- sudo apt-get install gcc g++ make
- To install the Yarn package manager, run:
- curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
- echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- sudo apt-get update && sudo apt-get install yarn
That's all steps that I did it. Hope you get the new experiment with the new version.
Paolo Phan