Install and run Ghost 1.0+ on a Raspberry Pi
Ghost 1.0 is here, but support for Raspberry Pi is almost non-existent. However, this guide explores how to install Ghost on your Raspberry Pi.
Update - 22 January 2018
It is now possible to install Ghost 1.0+ on Raspbian, so you may want to check out my latest post for the steps required to do this.
Those of you who have been following my step-by-step guide on how to install and run Ghost on a Raspberry Pi will know that Ghost recently underwent a radical upgrade to version 1.0.
Unfortunately, upgrading existing installs of Ghost hosted on a Raspberry Pi is not so straight forward. At the time of writing, Ghost is not fully supported in terms of installing on a Raspberry Pi but thankfully, GhostPi.pro has managed to get a test instance up and running and will be documenting the process accordingly.
What you'll need
In my test instance, I used the following:
- A Raspberry Pi 2 or 3
- Micro SD card (16GB or larger)
- Suitable power supply (5V, 2A)
- Ethernet cable (more reliable than Wi-Fi)
- Appropriate SD card image from below.
Now this is where things are a little different. In my previous guide, I used Raspbian Lite as the base image for setting up Ghost on my Raspberry Pi as it allowed me to install the relevant version of Node.js without having to remove the default one bundled with the full Raspbian image.
However, to install Ghost v1.0 and above on Raspberry Pi you need to use Ubuntu, so I opted for the Ubuntu Classic Server 16.04. You can find both of the SD card images on Ubuntu Pi Flavour Maker (although the Pi 2 image has been up and down recently so may not work):
- Ubuntu Classic Server 16.04 for the Raspberry Pi 2 (link no longer available)
- Ubuntu Classic Server 16.04 for the Raspberry Pi 3 (direct link to Pi 3 image)
If the Pi 2 version is not working, then try again at different times. For me, it worked some days but didn't on others, but once you have the image file then keep it safe. I'll explore the option for hosting a mirror here, but I cannot make any promises.
Obviously once you have downloaded the image file, flash it to your SD card. I won't go into detail here as there are countless guides available online on how to do this.
Ubuntu Classic Server 16.04 is a little different to Raspbian but similar in many ways too. To get you started, I highly recommend following these steps:
- Connect your Pi to your network via Ethernet cable as this speeds up the initial boot process and you will need to configure Wi-Fi manually once up and running
- Create a new user other than the default
ubuntu, but you do not need to do this if you don't want to
- Secure your Pi by using SSH keys and disabling password authentication. I have this page bookmarked and follow the initial steps relating to generating the necessary key files, as well as this one on what to do next whenever I do this
- Update and upgrade your apt packages then install the necessary packages and setup Wi-Fi - to save lots of writing and time, take a look at this fantastically helpful guide from step 4 onwards on what to do here.
You might wonder why you want to setup Wi-Fi if you are going to use your Raspberry Pi hosted Ghost blog via Ethernet, but this step just makes things a lot easier down the road. If you are planning on leaving your Pi hard-wired to your network, then you can skip the Wi-Fi part above.
Install the new Ghost Command Line tool
The guys and gals over at Ghost have done a wonderful job of creating a new command line installer tool, which guides you through the necessary installation steps. To install this on your Raspberry Pi, you will need to do the following:
[email protected] ~ $ sudo apt-get update && sudo apt-get upgrade -y [email protected] ~ $ sudo apt-get install nginx [email protected] ~ $ sudo ufw allow 'Nginx Full' [email protected] ~ $ sudo apt-get install mysql-server
The above string of commands will update and upgrade your packages, install Nginx then configure the firewall rules to allow full access for HTTP and HTTPS requests and finally install MySQL Server.
During the MySQL Server install, you will be prompted to input a password for your
root user, so make sure you use a strong password but also remember it as you will need it later.
Next, we'll download and install the latest version of Node.js that is supported by Ghost (v6.9.5 at the time of writing):
[email protected] ~ $ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash [email protected] ~ $ sudo apt-get install -y nodejs
Install the Ghost-CLI tool
The last step before we begin the Ghost install process is to install the Ghost Command Line Interface (CLI) tool:
[email protected] ~ $ sudo npm i -g [email protected]
This can take a while, so feel free to stretch your legs and grab a drink!
Prepare for the install
The last few steps are similar to my previous guide on installing Ghost on Raspberry Pi, where we created the necessary directories and give them appropriate permissions:
[email protected] ~ $ sudo mkdir -p /var/www/ghost [email protected] ~ $ sudo chown [user]:[user] /var/www/ghost [email protected] ~ $ cd /var/www/ghost
Remember to substitute
[user]:[user] with the user you created in the optional, but recommended step earlier on - i.e.
Kick off the install
Finally, we can now start the install process using the Ghost CLI tool:
[email protected] ~ $ ghost install
During the install process, you will be prompted to input various options including:
- Your blog's URL
- Your MySQL username (
- Your MySQL password (whatever you set it to when you install MySQL Server)
- Ghost database name (
- Whether you want a
- Whether you want to configure Nginx
- Whether you want to setup SSL
- Setup Systemd so you can start and stop Ghost easily
- Whether you want to start Ghost
If all has gone to plan, you should now have a Ghost blog installed on your Raspberry Pi running at least version 1.0. However, there is still some manual work required in order to access your new blog via any web browser.
In my next guide, I'll be guiding you through how I was able to install and run Ghost 1.0+ on a Raspberry Pi and configure Nginx manually so that I could access my blog via a web browser.
If you found this guide, as well as any other guides on Ghost Pi helpful, then if you wanted to buy Ghost Pi a coffee to show your support, then that would be greatly appreciated! As this site does not use any form of adverts, all the costs for running and maintaining the blog are done voluntarily so any extra would be fantastic!