Install and run Ghost on a Raspberry Pi

Follow this step-by-step guide to easily install and run Ghost on a Raspberry Pi, including how to use your own domain name and CloudFlare for free DDNS.

Install and run Ghost on a Raspberry Pi

Update - 22 January 2018:

Further to the update on 15 August 2017 below, it is now possible to install Ghost 1.x on Raspbian, so take a look at the latest install guide to get up and running in no time.

Update - 15 August 2017:

If you are looking to install Ghost v1.0.0 and above on Raspberry Pi, take a look at my latest post for the initial steps. The following steps below highlights how to install Ghost v0.11.0 and below on Raspberry Pi.

Install Ghost on Raspberry Pi (v0.11.0)

Ghost is a relatively new blogging platform, that is lightweight and easy to use. Whilst I'm not reinventing the wheel here, I have found that installing and running Ghost on a Raspberry Pi a little tricky, especially when it comes to using your own domain name and a DDNS service like CloudFlare. I've been inspired by other blogs that document various Ghost installations on Raspberry Pi, such as Alex Ellis' fantastic Docker themed blog, but I wanted to keep things simple for those of you, who like me, wanted to install Ghost on your Raspberry Pi manually.

To begin, we'll be looking at how to install Ghost on a Raspberry Pi and then we'll cover how to use your custom domain name via CloudFlare in the next post.

What you'll need

To install and run Ghost on a Raspberry Pi, you'll need:

  1. A Raspberry Pi (2 or 3 actually, this blog is running on a Model B now!)
  2. Micro SD card (16GB or larger)
  3. Suitable power supply (5V, 2A)
  4. Ethernet cable (more reliable than Wi-Fi)

That's it! The parts list is pretty small - obviously, you may want to keep your Raspberry Pi inside a case, but that's optional. I do recommend hard-wiring your Pi to your network, especially as you'll be hosting a blog as a result, as this is much more reliable than Wi-Fi.

Prepare your Pi

Begin by using the latest version of Raspbian Lite and create a fresh SD card using your preferred disk imaging software - i.e. Etcher or Win32DiskImager. We'll be using Raspbian Lite because it makes it easier for us to install Node afterwards as it is not included in the Lite version of Raspbian.

Now ensure you update your software on the Pi:

boo@ghostpi ~ $ sudo apt-get update && sudo apt-get upgrade

Once that has completed, do a little housekeeping on the Pi to remove unused dependencies and then removes any leftover files in the update repositories:

boo@ghostpi ~ $ sudo apt-get autoremove && sudo apt-get autoclean

Lastly, ensure that you expand the filesystem on your Pi to use all of your SD card's capacity:

boo@ghostpi ~ $ sudo raspi-config

Then choose option 1:

1 Expand Filesystem - Ensures that all of the SD card storage is available to the OS

Finish off by rebooting the Pi:

boo@ghostpi ~ $ sudo reboot now

Now we can move onto the next part.

Install Node.js v4.2.4 / v4.8.0 v6.9.5

Now this part really stumped me when I was following other guides on "How to Install Ghost on Raspberry Pi" as they all seemed to focus on installing the latest version of Node.js, which caused me a number of headaches when I was trying to install Ghost.

To get Ghost up and running on your Raspberry Pi, you'll need to install a specific version of Node.js - v4.2.4 UPDATE: Thanks to GainfulShrimp, who pointed out that you can use v4.8.0, I have now updated this post to reflect this - as this is one of the versions that Ghost themselves recommend.

UPDATE - 15 August 2017: You can now use an even newer version of Node.js to run Ghost on Raspberry Pi, so this guide has now been updated to reflect the use of v6.9.5 as this is the LTS version for using Ghost on Raspberry Pi.

Essentially, you can use any of the 27 versions from v4.2.0 through to v4.8.0 and Ghost will work fine on your Raspberry Pi. I now highly recommend using v6.9.5, but I've been fine using v4.2.0 and v4.8.0.

Thankfully, this is a simple process if you use Raspbian Lite as this lightweight version of Raspbian does not have any version of Node.js installed.

For Raspberry Pi Model B

The Raspberry Pi Model B uses ARM6, so we need to download the appropriate version Node.js using the commands below:

boo@ghostpi ~ $ wget
boo@ghostpi ~ $ sudo mv node-v6.9.5-linux-armv6l.tar.gz /opt
boo@ghostpi ~ $ cd /opt
boo@ghostpi ~ $ sudo tar -xzf node-v6.9.5-linux-armv6l.tar.gz
boo@ghostpi ~ $ sudo mv node-v6.9.5-linux-armv6l nodejs
boo@ghostpi ~ $ sudo rm node-v6.9.5-linux-armv6l.tar.gz
boo@ghostpi ~ $ sudo ln -s /opt/nodejs/bin/node /usr/bin/node
boo@ghostpi ~ $ sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm

For Raspberry Pi 2 or 3

The Raspberry Pi 2 or 3 uses ARM7, so we need to download the appropriate version Node.js using the commands below:

boo@ghostpi ~ $ wget
boo@ghostpi ~ $ sudo mv node-v6.9.5-linux-armv7l.tar.gz /opt
boo@ghostpi ~ $ cd /opt
boo@ghostpi ~ $ sudo tar -xzf node-v6.9.5-linux-armv7l.tar.gz
boo@ghostpi ~ $ sudo mv node-v6.9.5-linux-armv7l nodejs
boo@ghostpi ~ $ sudo rm node-v6.9.5-linux-armv7l.tar.gz
boo@ghostpi ~ $ sudo ln -s /opt/nodejs/bin/node /usr/bin/node
boo@ghostpi ~ $ sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm

The above commands will download Node.js version 4.2.4 / 4.8.0 6.9.5, move the tar file to the opt directory, extract the contents of the tar file, move the extracted files to the nodejs directory, remove the leftover tar file then create symbolic links between the relevant node and npm directories.

Once you've that, check that Node.js is installed by running:

boo@ghostpi ~ $ node -v
boo@ghostpi ~ $ v6.9.5

All being well, you should now see v4.2.4 / v4.8.0 v6.9.5 in the terminal. Hurrah! At this point, it might be worth rebooting your Pi just for good measure:

boo@ghostpi ~ $ sudo reboot now

Install Ghost

You'll need to download the latest version of Ghost via the command line on your Pi. This might look daunting, but it's really simple:

boo@ghostpi ~ $ cd ~
boo@ghostpi ~ $ wget

This will change you to your home directory and then grab the latest version of Ghost in a zip file directly from Ghost itself. We'll now be unzipping this to a specific location - it doesn't have to be here, but I recommend it. Let's create the directories first:

boo@ghostpi ~ $ sudo mkdir /var/www
boo@ghostpi ~ $ sudo mkdir /var/www/ghost

Now we'll unzip the Ghost files to the newly created directory:

boo@ghostpi ~ $ sudo unzip -d /var/www/ghost

We'll need to use the sudo command as the Pi user doesn't have write access to the /var/www/ghost directory, but we can change that by changing the ownership of the directory and its contents with:

boo@ghostpi ~ $ cd /var
boo@ghostpi ~ $ sudo chown -R pi:pi www/

Now change to the new directory we just unzipped the Ghost files to:

boo@ghostpi ~ $ cd /var/www/ghost

The next stage is to install Ghost, which is done using the following simple command:

boo@ghostpi ~ $ npm install --production

This may take a few minutes, so now is a great time to stretch your legs, rest your eyes and get a drink.

Once the installation is complete, you'll be returned to the command line (hopefully without any errors) and then we can start configuring Ghost - after all, we don't just want to host Ghost on our Raspberry Pi without making it our own do we?

First, we need to create a configuration file for Ghost to use. Luckily, there is an example already in our Ghost installation directory, but we just need to copy this:

boo@ghostpi ~ $ cp config.example.js config.js

This command tells your Pi to copy the config.example.js file to a new file called config.js. Now at this point, I had to change a setting in this new configuration file so that I could open up my new Ghost blog in a browser:

boo@ghostpi ~ $ nano config.js

The part you'll need to change is:

server: {
    host: '',
    port: '2368'

To (replacing with your Pi's IP address):

server: {
    host: '192.168.x.x',
    port: '2368'

Ctrl+X and Y to save and exit.

Start Ghost

Before diving into configuring our Ghost blog, let's just be sure it works first! This can save a lot of headaches further down the line, as if it doesn't work here, then something went wrong with the install, and not as a result of something you did when configuring Ghost!

Whilst in the /var/www/ghost directory, run the following command to start Ghost in production mode:

boo@ghostpi ~ $ npm start --production

If all goes well, you should see a lot of activity on the command line, which should end with something like:

boo@ghostpi ~ $ Listening on 192.168.x.x:2368
boo@ghostpi ~ $ Url configured as:
boo@ghostpi ~ $ Ctrl+C to shut down

Now before you shutdown the blog, test it works by going to http://192.168.x.x:2368 in your browser. If all goes well, you should see your Ghost blog!

Next steps

Now that your Ghost blog is up and running on your Raspberry Pi, you can begin the next steps and configure it to your liking. But first, why not get familiar with how Ghost works? For instance, did you know you can log in by browsing to http://192.168.x.x:2368/ghost, but the first time you do this, you'll be asked to create an account?

In the next guide, we'll be covering the more granular parts of configuring Ghost, including using a custom domain name and using CloudFlare DDNS to provide some protection to our Raspberry Pi Ghost Server, so subscribe below and be notified when this is live.

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!

Buy Me A Coffee