Please Note - This article is currently a work in process. Once this is completed, this notification will be removed. Because of all of the issues I have been having, that is why this I am publishing this, and editing as I go, in case others are trying to update their Ghost Blog set up in a similar way.
Because I like ensuring that I am on the latest version of software with whatever I am running, when Ghost announced v1 was finally released for production, I wanted to install it straight away! I found that this was not so easy on the Raspberry Pi Zero W - mainly due to the minimal hardware on the device.
As such, and because the v0.11 needs to be stopped so that v1 can be installed, after 1 week of downtime trying to troubleshoot the install, I have now set up the blog onto one of the smallest Droplets on Digital Ocean. Once this has been finished and I can actually get this running, then it will be migrated back.
Process
SSH into your server, and run the following commands.
cd /var/www
sudo supervisorctl stop ghost
sudo mv ghost ghost-old
sudo mkdir ghost
sudo npm install -g ghost-cli
On the Pi Zero W, with the limited hardware, this install of the Ghost CLI will take around 30-40 minutes. So feel free to leave this and come back to it.
Once that is completed, run these commands.
sudo apt-get update
sudo apt-get install mysql-server
Set a MySQL root password, and write it somewhere secure for later reference.
Now, Node needs to be updated to v6. This needs to be installed manually as they only come as tarballs for Raspberry Pi apparently.
cd ~
wget https://nodejs.org/dist/v6.11.1/node-v6.11.1-linux-armv6l.tar.gz
tar -xzf node-v6.11.1-linux-armv6l.tar.gz
node-v6.11.1-linux-armv6l/bin/node -v
cd node-v6.5.0-linux-armv6l/
sudo cp -R * /usr/local/
sudo npm i -g ghost-cli@latest
It was at this point that I ran the ghost install
command, however it failed after about 15 minutes showing the following error.
A ProcessError occurred.
Error occurred running command: 'yarn install --no-emoji --no-progress'
Exit code: 1
Looking at the Ghost Docs, this says it was most likely a swap thing, even though the error when looking at it in the log states
warning There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz: ESOCKETTIMEDOUT".
So, I modified the swap file. By default there is one, however it is only 100MB. I increased it to 1GB.
sudo swapoff -a
sudo dd if=/dev/zero of=/var/swap bs=1M count=1024
sudo mkswap /var/swap
sudo swapon /var/swap
Thinking that this should be all that is required, i ran ghost install
again, and got the exact same error message.
Tried again while monitoring the swap file, as I wanted to see why it would be filling even 1GB of swap, and it didn't even touch the swap file - it got to a max swap usage of about 10MB.
As it mentioned network troubles in the log, I tried running wget https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz
and had no issues whatsoever. This is very odd.
I tried manually running yarn install lodash
to test that, and no issues there either.
'Giving Up'
It is at this point where I 'gave up', and created a Digital Ocean Droplet, which ran and installed Ghost v1 with no issues (apart from the fact that the tiny instance needed a swap file set up to run the Ghost installer, but unlike the Pi, this ran without issue after a swap file was added), and is what I am editing this blog post on. If and when I get this working, then it will go back to the Pi, and kill the Droplet.
Now that my blog is back up and running, I am not so worried about how long it takes to get this back up and running on the Pi, only that it will cost me $5USD/mth to run the Droplet until i am able to kill it.
Continuing On with Setup
Now that I have an active blog on Ghost v1, I also have a reference to see how far the Pi is actually going. Reading further into the Ghost Docs, it states the following.
Ghost will then be downloaded from npm and installed into the /versions/ folder. A symlink is created from /current/ to the latest version. Ghost is now installed.
So therefore I ran ln -s /var/www/ghost/versions/1.5.0/ current
to symlink the folder. Then I tried ghost setup
but it failed, stating it was not a valid install. looking at the folder structure, I noticed one file which I inspected. cat .ghost-cli
{
"cli-version": "1.0.3",
"active-version": "1.5.0",
"name": "blog-title",
"extension": {
"systemd": true
},
"running": "production"
}
I re-ran ghost setup
and it worked! Sort of... Even though I was editing it under the ghost user that was set up, I assume that because I created the file using sudo nano
that is the reason it had its permissions set to pi as the user. running chmod
and running ghost setup
again and it ran successfully up until the migration section.
Message: 'Command failed: knex-migrator-migrate --init --mgpath /var/www/ghost/current
NAME: InternalServerError
MESSAGE: Please provide a file named MigratorConfig.js in your project root.
So it looks like it still hasnt downloaded all of the necessary components to run properly, and also trying to run ghost ls
also comes up with an error.
/usr/local/lib/node_modules/ghost-cli/node_modules/yargs/yargs.js:1079
And this is where I have currently left it tonight (05/08/2017). I will update this blog post when I continue on this task. I have posted questions on the Ghost Slack channel, but I never seem to get a response from anyone. If anyone is reading this and has any ideas to assist, please comment, or find me and my queries and reply on the Ghost Slack channel.