Installing Ghost 1.x on a Raspberry Pi - A Test, Development Blog
This summer Ghost underwent major changes when it moved up to version 1.0. One of these changes was a new command line interface which also installed Ghost itself.
The font of Ghost installation knowledge on a Raspberry Pi is https://ghostpi.pro who had a post dated August where it was suggested that Ghost 1.0 no longer installs on a Raspberry Pi running Raspbian but needs Ubuntu 16.04. I thought I'd explore the problem and see where the errors lay with little hope that I'd be able to fix them - but 4 months is a long time in software and the latest Ghost 1.19.0 (at least) installs on a Raspberry Pi without problem. In fact, the ghost-cli installer makes the whole process even easier than previously.
Let's do an install from a fresh raspian-stretch-lite image (in my case it just happened to be the image dated 29-11-2017
After installing the image and whilst still on the install computer as opposed to the Raspberry Pi I added an empty file ssh to the boot partition to allow for SSH to the Raspberry Pi immediately - so I didn't need to hook up a monitor and keyboard to the Raspberry Pi. I also edited the file /etc/dhcpcd.conf to give the Raspberry Pi a static IP address. Much easier to find it than using dhcp.
Then SSH to the Raspberry Pi, login and make sure all the software is up-to-date
sudo apt-get update && sudo apt-get upgrade
and change the default password, reduce the amount of graphics memory and expand the file system using raspi-config
sudo raspi-config
which needs a reboot to take effect.
We'll use Sqlite3 rather then MySQL so need to install it:
sudo apt-get install sqlite3
Next, install nginx
sudo apt-get install nginx
nginx needs a tweak for ghost.
Edit /etc/nginx/nginx.conf and uncomment
server_names_has_bucket_size 64;
Now install node.js - 6.9.5 is the recommended version for Ghost.
wget https://nodejs.org/dist/v6.9.5/node-v6.9.5-linux-armv7l.tar.gz
sudo mv node-v6.9.5-linux-armv7l.tar.gz /opt
cd /opt
sudo tar -xzf node-v6.9.5-linux-armv7l.tar.gz
sudo mv node-v6.9.5-linux-armv7l nodejs
sudo rm node-v6.9.5-linux-armv7l.tar.gz
sudo ln -s /opt/nodejs/bin/node /usr/bin/node
sudo ln -s /opt/nodejs/bin/npm /usr/bin/npm
Once node.js is installed we can install ghost-cli
sudo npm i -g ghost-cli@latest
sudo ln -s /opt/nodejs/bin/ghost /usr/bin/ghost
We probably don't need yarn but the node.js install suggested it might be useful so why not install it now
curl -o- -L https://yarnpkg.com/install.sh | bash
We're now ready to install ghost itself, so let's make the directory for the blog and ensure we have all the permissions we need.
sudo mkdir /var/www/ghost
sudo chown -R pi:pi /var/www/ghost
and install ghost in to it - NOTE this takes quite a while, be patient!
cd /var/www/ghost
ghost install local
And that's it. If you want to access the test Ghost from a different computer on your LAN you need to edit config.development.json. Change the first "url" line from localhost to the actual IP-Address of your Raspberry Pi Ghost server and similarly change the "host" line a couple of lines lower to also refer to thesame IP-Address rather than 127.0.0.1
Restart Ghost with
ghost restart
and you should be able to access yor blog from within your LAN on IP-Address:Port