You will need: Raspberry Pi + Raspbian (HF) + node.js, the Internet, basic SSH skills
Estimated duration: 45 minutes
This tutorial will take you through installing the Ghost blogging platform on a Raspberry Pi, complete with Forever to keep it running.
Itâs based on the main tutorial from ghost.org, but since I had a few problems with that I made some modifications.
First up, if you donât already have it install node.js from my guide here (thereâs a link back to this page at the end).
With the latest version of node.js installed, grab yourself a copy of SQLite 3 - this should be installed during the Ghost installation but in my experience, preinstalling it reduces errors:
sudo apt-get install sqlite3
Next, create a www
folder in /var
. If youâd rather run Ghost from somewhere else, youâre free to amend this part. I just like having it in /var/www/ghost/
because it feels right:
cd /var
sudo mkdir www
cd www
sudo curl -L https://ghost.org/zip/ghost-latest.zip -o ghost.zip
sudo unzip -uo ghost.zip -d ghost
sudo rm ghost.zip
That last command deletes the Ghost zip file, you can skip it if youâd like to keep a backup.
cd ghost
sudo npm install --production
Thisâll take a while. Mine took around 15 minutes. When itâs done, Ghost is installed. You can run it in development mode with npm start
if you want, but you wonât see much for now.
Make a copy of the example configuration file, edit it and replace the production URL with the one you plan to run your blog at:
sudo cp config.example.js config.js
sudo nano config.js
Youâre looking for:
production: {
url: 'http://my-ghost-blog.com',
Donât bother changing the development: {
URL because you wonât be using development mode.
If you want to access Ghost directly like this, youâll need to change its production port to :80 - if you want to put it behind Varnish Cache to dramatically speed it up and reduce load on your Raspberry Pi, follow the link at the end of this tutorial.
Now letâs get Forever running. Thisâll monitor your Ghost instance and make sure itâs restarted if it fails for any reason:
sudo npm install forever -g
Yeah, thatâs pretty much it for that one. Nice and simple. You can test Forever by running:
sudo NODE_ENV=production forever start /var/www/ghost/index.js
Alternatively, skip it and create the Forever startup script instead:
sudo nano /etc/init.d/ghost.sh
And paste the following into it:
#!/bin/sh
sudo NODE_ENV=production forever start /var/www/ghost/index.js
Make it executable and set it to run at startup:
sudo chmod +x /etc/init.d/ghost.sh
sudo update-rc.d ghost.sh defaults
Reboot:
sudo reboot
And, when youâve logged back into the Pi, check that itâs working:
sudo forever list
If everything went okay, you should see something similar to the following:
If you do, great! Youâve got Ghost running âForeverâ automatically at boot on your Raspberry Pi.
Any problems, check the original Ghost guide or drop me a line in the comments (when I enable them).
Following âhow to run Ghost effectively from a Raspberry Pi?â
Next tutorial: How to install Varnish Cache on a Raspberry Pi