Build your own professional blog with Ghost, and host it yourself on your own VPS/Raspberry PI with Docker!

I recently came across Ghost, a professional, open-source, blog CMS.
I use the 14 days free trial to try it out, and had a really good experience. My only concern was the cost of the SaaS solution, 19€/month if billed annually, for a starter pack (29€ monthly), which, either case, is a bit too expensive.

But, Ghost is open-source, meaning you can get the source code for free! (MIT)
Also, they have a Slack server where you can ask questions, very useful! And the people are nice there :)

So, if you like the Ghost blog, you can either use the SaaS version and everything is done for you, like the setup, backups, you get the new features automatically as well, you can use another theme if you don’t like the main one (which is really good by the way, I’m not planning on changing anytime soon).

But, if you want to manage your blog yourself, like adding extra features or changing the core behavior, but keep it super easy to maintain, here is how I did it.

At the end, I’ll present a cost estimation between several possible solutions, including hosting Ghost on a Raspberry PI!

I. Get your own VPS (Virtual Private Server)

This is basically the server on which Ghost will run. After looking and comparing for a while, I chose OVH, both for their pricing and performances. I took the VPS SSD 1 for 3.59€/month, with 2Go RAM and 10Go disk space.
It’s likely that 10Go disk space won’t be enough to host your content. The OS you install will take about 7.5Go anyway so you won’t have much left for the content. But you can add additional hard drives (100Go for +4€/month)
Whether you use OVH or not is up to you, you may want another provider and that’s fine.

You should get something like this, if you’re using OVH.

OVH VPS panel
Alternatively, you could also avoid paying for a VPS and host your blog on a Raspberry PI, at home. Definitely cheaper!
I won’t go into technical details for the Raspberry PI hosting, but if you’re the DIY kind of person and you’d like to check it out, this repo is just awesome!

II. Install Docker

Once you got your server up and running, you need to do a basic setup like installing Docker. Personally, I installed Ubuntu 14.04 LTS with Docker pre-installed for the sake of simplicity, when I chose my VPS OS.

You can chose Docker, which automatically will run on Ubuntu 14.04

If you missed this information, don’t worry. You can either reinstall your VPS with Docker pre-installed, or simply install Docker through command line.

If you wish to go for the CLI installation, please follow one of the official tutorials (ubuntu in this example).

III. Install and run your blog locally (testing)

Now that Docker is installed, you need to install Ghost. To do so, we will use an official Docker image.

Run this command and you will have a Ghost instance up and running on your port 3002 (assuming you’ve got nothing else running there already).
The urlenv var is used by Ghost internally. Basically for the links and stuff like that. (invitations, etc.)

In this example I’ve used ghost:1.12.1-alpine which is the latest Ghost version (at the moment). We use Alpine which is a very lightweight Linux (5MB), takes less space on the disk, and is faster to download.

Note that the -v option creates a volume on the host at /var/www/blog here. This is very important because it means you can stop/kill your docker instance without losing the data. Note that if the host itself is lost, you’ll lose the data regardless.

By “data”, we mean the database (sqlite), images, themes and apps.

You can now start or stop your container as you want, it won’t affect the data in any case.

IV. Run your blog online

You problably have a domain name like http://my-blog.com through some provider, and you want to simply redirect to whatever IP your VPS is running on.

Of course, you don’t want your users to go to http://my-blog.com:3002, that’s fairly obvious. And you probably don’t want to have to setup nginx, or apache, or both. (if you don’t know what those are, that’s no big deal!)

So you’ll need a proxy which will understand that a request coming from http://my-blog.com should be redirected to http://localhost:3002 (in our case).

To do so, we will simply run another Docker container, which will handle the complicated logic and setup for us: https://github.com/jwilder/nginx-proxy
Assuming you have nothing on port 80 already, which is the case if you’re on a new VPS.

Run nginx-proxy to handle all incoming requests on port 80

And now, the last thing you need is to make your blog online!

Run your blog and serve it when a request comes from a virtual host

This will redirect all incoming traffic from my-blog.com or www.my-blog.com to http://localhost:3003 !

It’s done! You’ve got a blog up and running with only 2 command lines once Docker is installed. Talk about simplicity? :)

Setting up your Ghost takes only 2 command lines! It’s then immediately accessible online! Here it’s on http://54.37.8.38:3003/
You only have to setup a redirection from http://my-blog.com to your VPS IP address which is http://54.37.8.38 in this case, and that’s it!

V. Automated backups

You probably want to protect your blog with automated backups, butit’s not as simple as what we did before.

I’ve used Rsync.net provider which provides me with a 100Go hard drive for $8/month. On the VPS, I have a cron running several times a day, basically doing a backup and uploading it to Rsync server.

Since it’s a little technical, I invite you to come and read my GitHub in-depth explanation for those interested!

VI. Additional disk space

If you used a VPS using OVH as I did, you’ll soon run into a big issue: Hard drive space. You can either take a bigger VPS, or simply add an additional disk. Taking a bigger VPS makes sense if the VPS resources are too highly used. (the RAM, mainly)

Also, this low-cost VPS doesn’t allow for extra options like automated backups. But with a Cloud VPS such as https://www.ovh.com/us/vps/vps-cloud.xml then you can have this additional feature managed for you (at the cost of +8€VAT/month in addition to the Cloud VPS)

A 50Go additional disk cost 5€ VAT/month.

Note that it’s cheaper to use the OVH Public Cloud. The VPS will cost the same, but for some reasons the additional hard drive is much cheaper there. (4€ VAT/month for 100 Go)

VII. Cost comparison

Cost comparison between OVH, Raspberry PI and Ghost.io

A few improvements could be to use the OVH Public Cloud for 4€/month, granting 100Go, and to move from Rsync to something hosted on OVH who could be cheaper, like a Volume? Not quite sure, but there is probably cheaper solution out there for the backups part.

There is not so much cost difference between my solution and the Ghost.io pricing. But hosting it on my VPS allows me to use my own, customized version of Ghost.

The use of a Raspberry PI is totally possible, and very cheap. But it won’t be able to handle too many requests, and you will have to plug and external hard drive to it (I suppose) to increase its storage capacity.

Better alternatives?

Do you know better/cheaper alternatives? (Ghost requires at least 1Go RAM)

Let us know!