Building on my last post about moving ds106.club off Amazon Web Services (AWS), I moved another EC2 instance I setup back in 2014 to run the blogging platform Ghost. Like ds106.club, I had not been able to access the server for a while, and the hassle of replacing the key pair was preventing me from doing anything. To make matters worse I was unable to access the dashboard of Ghost given I got into a bad password reset loop (this stems from larger issues of not getting my SMTP settings right).
I was able to ignore these issues because I had only been doing some preliminary experimenting with Ghost, and it was running on a free tier at AWS and by no means mission critical. But when I started the process of moving ds106.club, it only made sense to move my Ghost blog as well.
After having already figured out how to download my data from the ds106.club storage volume while trying to replace my key pair, doing this for my Ghost install was pretty easy. I removed the storage volume from the existing instance and mounted it on a temporary instance so I could access and download all my files, database, etc. After that, I headed over to Digital Ocean and installed a $5/month instance running Ubuntu 14.04 and used this tutorial to get Ghost up and running with Nginx.
That all worked well, and I had a clean Ghost instance up and running on Digital Ocean in no time. Unfortunately without access to the old Ghost dashboard I couldn’t get an export file, but I was able to download the database and images so that was a bonus. Turns out I couldn’t get my new ghost instance to read the imported database (anyone have tips on that), so I did a manual copy and paste of the four existing posts on the Ghost blog from bavatuesdays (glad I cross-posted).
After that I was back in business again on my own server through Digital Ocean running a Ghost instance. I was happy! But when I woke up Saturday morning and checked the site it was gone, just a clean Ghost instance with no sign of any of the content I loaded. I was sad! I’m still not sure why this happened, I have a hunch it might have something to do with my loading the forever
module, which monitors to make sure Ghost is up, and if and when it crashes another instance of Ghost will start automatically.
So, I installed Ghost again, but this time on Reclaim Hosting! We have a server that runs Ghost instances using Docker containers for folks that are interested (something we no longer advertise given the limited uptake). So, I decided to figure that out given it is something Tim setup in-house.
I enjoy writing in Ghost, and while it has been over two years, i can see this being a slick blog tool. I still want to export all the content in bavatuesdays to ghost just to see if it is possible, but I guess we’ll have to see about that. There are comments, URLs, etc. that would be quite complicated, but I guess that’s the idea behind a test.
Anyway, on a more technical note below are some steps and notes that document the process for spinning up an instance of Ghost via Docker containers on our server. Not sure how broadly applicable it is, it will most likely only serve as a potential future guide for me given how quickly I forget this stuff:
First command once in the home directory on the Reclaim Ghost server is copying the existing template we created for any future Ghost instances, which will use the url as their title, namely ghost.murderinc.biz:
cp -R template ghost.murderinc.biz
Once the template has been copied, I went into the ghost.murderinc.biz directory and edited the startBlog.sh file. Replacing anY instance of Tim’s blog URL, blog.timowens.io, with ghost.murderinc.biz. I also changed the name, in my case bavaghost. The startBlog.sh script will look something like this:
docker run -e "VIRTUAL_HOST=ghost.murderinc.biz" --volumes-from blogVol --name bavaghost -p 49153:2368 -v /home/ghost.murderinc.biz:/ghost-override -d timmmmyboy/ghost
The port 49153 would need to be changed to something different for subsequent Ghost installs, something like 49154, etc.
After that you want to also edit the config.js file. You want to change the production URL field to your URL and rename the database file to something like:
database: { client: 'sqlite3', connection: { filename: '/data/bavaghost.db'
This is also where you would set the email settings, but I am going to deal with that in a separate post. I’ll link back to that once I do. After that you would run the following command:
sh startBlog.sh
That should get your Ghost site up and running, and you can double check it is up by
running the following command:
docker ps
If it’s running your Ghost container will show up there. If for any reason you have issues and need to stop the container and remove it, here is the command for that:
docker stop bavaghost && docker rm bavaghost
And full credit for the original setup this was based on https://github.com/sethbrasile/blog/blob/master/README.md. We just happen to use the Nginx part so that we can run more than one blog off a single server.
That’s good to know in terms of where you got the setup. You ever run into any issues with the forever module for Ghost? You ever try it?
I think I probably tried setting up Ghost manually once and it used it. But it’s really just used because Node JS processes have to always be running (unlike PHP which can be executed when the site loads) so the forever module just makes sure node is running and if it isn’t it restarts it. Shouldn’t have corrupted the database or anything weird like that.
I hope you understand the consequences to your soul when playing with spirits like this!
Does it mean I’ll be doing ceramics in the kiln of hell?! 🙂