How to Migrate From Ghost 1.x.x to 3.x.x
The Ghost Version 1.x.x can't be updated automatically anymore. Therefore, it needs to install the lastest version of Ghost and migrate all the old data to the new Version to keep getting updates. This tutorial will help to achieve this
- Make a Backup
Always take a backup of everything you will be modying. In this Case, The Ghost Directory.
2. Export your content
From your Old Ghost blog use the export function to get a JSON export of your Posts. (NO Themes or Images).
Click Labs > Export your content > Export
3. Export Your Themes
From Your Old Ghost Blog use the download button to backup your Theme and Go to https://gscan.ghost.org/ to check if the theme will have compatibility issues with the new Update before upgrading. (if you are using only the default theme, casper, dont worry).
4. Export the Images
Backup the content folder manually. The Images are found in the Ghost Directory > Content Folder.
Usually /var/www/Ghost_directorty/content
Installing Ghost on Ubuntu
Updating Packages
# Update package lists
sudo apt-get update
# Update installed packages
sudo apt-get upgrade
Installing Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Installing My SQL
# Install MySQL
sudo apt-get install mysql-server
MySQL on Ubuntu 18.04 or 20.04
# To set a password, run
sudo mysql
# Now update your user with this command
# Replace 'password' with your password, but keep the quote marks!
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
# Then exit MySQL
quit
Installing Node.js
# Add the NodeSource APT repository for Node 12
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash
# Install Node.js
sudo apt-get install -y nodejs
Installing Ghost-CLI
sudo npm install ghost-cli@latest -g
Create a Directory
# Create directory: Change `sitename` to whatever you like
sudo mkdir -p /var/www/sitename
# Set directory owner: Replace <user> with the name of your user
sudo chown <user>:<user> /var/www/sitename
# Set the correct permissions
sudo chmod 775 /var/www/sitename
# Then navigate into it
cd /var/www/sitename
Install Apache2
sudo apt-get install apache2
sudo ufw allow 'Apache'
apt-get install -y libapache2-mod-proxy-html libxml2-dev
Configuring Apache2 to reverse proxy
install the required Modules:
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_ajp
a2enmod rewrite
a2enmod deflate
a2enmod headers
a2enmod proxy_balancer
a2enmod proxy_connect
a2enmod proxy_html
Setting Up the Proxy Configuration
Disable the default configuration
a2dissite 000-default
The Directory is /etc/apache2/sites-avaliable/
Create a Directory for Ghost
nano /etc/apache2/sites-availiable/ghost_Config_name.conf
The .Conf file should have these to configure HTTP and HTTPS:
<IfModule mod_ssl.c>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
RequestHeader set X-Forwarded-Proto "https" ServerName <The Server Address> ServerAlias <www.The Server Address>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
# LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host.
SSLEngine On
SSLProtocol ALL -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
#Specify the Path to the Certificate
SSLCertificateFile /Location/of/certificate/fullchain.pem
SSLCertificateKeyFile /Location/of/certificate/privkey.pem
<Location "/">
ProxyPreserveHost On
ProxyPass http://127.0.0.1:2368/
ProxyPassReverse http://127.0.0.1:2368/
</Location>
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName <The Server Address>
ServerAlias <www.The Server Address>
ProxyRequests Off
ProxyPass / http://127.0.0.1:2368/
ProxyPassReverse / http://127.0.0.1:2368/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
#RewriteCond %{SERVER_NAME} =www.$host [OR]
RewriteCond %{SERVER_NAME} =<The Server Address>
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
</IfModule>
Enable virtual Host File
a2ensite <name of the file.conf>
Restart the Apache Service to apply changes:
/etc/init.d/apache2 restart
if you are using NGINX please stop the service because apache will run in port 80 too.
service nginx stop
Run Ghost Installation
To run Ghost Installation Nagivate to the Ghost Directory Using the su user (NOT ROOT).
ghost install
Install Directions:
- Blog Url: http or https:// Url or IP Address/
2. MySQL hostname: Localhost
3. MySQL username/password
if you have a MYSQL database enter the username if not then enter root. The user's password will be asked.
4. Set Up ghost MySQL user? YES
5. Set up SSL? If you are using HTTPS type YES. Ghost-CLI will automatically set up SSL using Let's Encrypt.
6. Set up systemd? YES
7. Start Ghost? YES
To uninstall Ghost
ghost uninstall
To re-run the Ghost Setup
ghost setup
To check the Ghost Status
ghost status
If having trouble accesing Ghost website please restart it:
ghost restart
Copy your old data to your new server
After configuring Ghost with the Address http(s):// IP address or URL/ghost (dont user www.)
Go to Labs> Delete All content
To avoid any issues before the migration.
Import JSON file
Go to Labs> Import Content > Import
Import the JSON Backup to get all the posts and Users
Import Theme
If your Theme is compatible with the new version of Ghost (check this website: https://gscan.ghost.org/ )
Go to Design > Upload a Theme.
Import Images
Overwrite the Content Folder in your Ghost Directory from the Backup you made at the beginning.
Can be done using mv if its already in the Server, winSCP if its in another server, or SCP command to copy from other server using terminal.
refresh or Restart Ghost after Overwriting the content folder.
ghost restart
You are all set!
References: