The beginning... a Google Cloud Platform journey

So - lets talk about this website and the Monday that led to its creation.

Now - there are few joys in life as apparent as a sleep-in in a warm bed on a cold morning - it was in the waking moments of such a circumstance that I found myself thinking of ways to spend the day. I’d been learning about the cloud recently and whilst I had hours of training to get through something more hands-on felt more inspiring.

A concept slowly began to come together - a website, hosted on the cloud, for less than a cup of coffee - finished today.

  • Priority number #1 - cloud hosting

  • Priority number #2 - low cost

  • Priority number #3 - quick and easy (hahaha)

Defining my goals for this same day ‘sprint’

To have a Wordpress site installed on a self-hosted cloud platform, routing via a Cloudflare layer to a domain name of my own with HTTPS making everything secure.

My definition of done was to have everything pass standardised testing from the command line, and to have an operating cost of less than a cup of coffee per month (we’ll say $5 for transparency).

Exploring priorities #1 and #2 quickly lead to Google Cloud Platform - the only big three provider with an always free compute tier. I’ve been studying AWS (aiming for the CCP, and SAA exams by end of year) however their offerings weren’t a perfect fit for the project.

Priority number #3 was largely thinly veiled optimism. However, some quick googling found that people had created projects with similar goals on GCP successfully. At the very least - this provided the framework to put this idea into action.

So, in the early afternoon the project began in earnest.

Step #1 - Creating the machine serving as the base for this project.

First thing first on ANY Cloud platform - set up a billing alert. No really - go do it.

Once that’s done - time to make our compute engine. At the time of writing GCPs free VM instance is the f1-micro (1 vCPU, 0.6 GB memory), 30 GB HDD. I chose the Ubuntu 18.04 LTS Minimal image - I am running Ubuntu 20.x on my home server so this seemed like a safe choice(this turned out to be a mistake but more on this later) - I assumed the 18.04 image would be slightly less of a weight on the fairly minimal configuration I was operating with. HTTP/HTTPS was allowed, and an ssh key was generated and added so I could use terminal locally on my device. Your configuration should look something similar to this:

Fairly straightforward so far.

GCP also gives you a ~$300 value of credit to use when you first sign up. Conveniently you can register domains through GCP (via Cloud Domains) and whilst this does come at a monthly cost you can use your credit towards it.

Step #2 - Setting up the Cloudflare layer.

This was my first time dealing with Cloudflare but was a breeze of a process - create an account, update the name servers on the Domain Name registrar (GCP in our case), and then edit the DNS records. Two are needed:

  • A record - with the domain as “yourdomain.com" and the value as the public IP of your Google instance.

  • CNAME entry where name =“www” and value=“yourdomain.com"

Now DNS records can take up to 24 hours, but in my experience so far by the time we’ve done the rest it should all be up to date.

I forgot to edit the DNS records when I first finished up and then wondered why I wasn’t seeing anything on my domain - definite facepalm moment when I realised.

Step #3 - Install a LEMP stack and Wordpress.

This is where things started going poorly - the first tutorial followed was fantastic - Ubuntu 18.x was even the base of the stack! It all went fantastically until I loaded up Wordpress and immediately was informed that php was out of date (the tutorial used 7.2 versus current). No problem - back into the command line to update it all.

An hour later down that rabbit hole, things were a lot more broken than they began. mySQL was depreciated with php7.4, and in recreating the database for mariaDB something broke. Lesson learnt - sometimes it’s easier to cut your losses and start an install from scratch with up to date resources.

With the click of a button or two, and one f1-micro is deleted and another is made. I decided to then jump to the other end of the extreme Ubuntu 20.x, and php8.0 - this was the answer I was sure - until the VM kept hitting its memory limit and becoming unresponsive.

Once more the instance was deleted, and a new one made. Ubuntu 20.x, php7.4 (and extensions) installed without fault (and no unresponsiveness!). Ngninx and MariaDB shortly thereafter - the stack was finally complete. Once done, installing and configuring Wordpress was the next mountain to tackle.

With the correct guidance this proved to be much more straightforward than the rest of the journey thus far. Slow but sure steps in the right direction. Once the install and configuration was successful, and I could see the install wizard on my domain I was almost at the home stretch.

Enabling HTTPS was the final checkbox - this was done by an installing a free TLS certificate from Let’s Encrypt with certbot.

This ended up timing pretty perfectly with my one other commitment of the day! (Pfizer jab #1).

Step #4 - Following the Wordpress install wizard, and bug fixing.

The hard part of the process was done (or so I thought) - I was finally in. Theme changed successfully? Check. First post written? Check. First post posted? Offline? Wait? What?! Caches cleared and issue persisted. Back to default theme? Nope. Different browser? Still broken. Pinging the domain was successful. GCP showed the server as being up - what gives?

Wordpress includes a ‘Site Health’ tool which showed I was having a REST API issue. This ended up being resolved by installing the Cloudflare plugin, and allowing it to apply recommended Cloudflare settings for Wordpress.

Et voilà - first post successful. (Hello World!).

I’m still running into an issue where editing pages will be unsuccessful and bring up an error, my current work round is using the Wordpress Classic Editor - I’ll update this once I’ve figured out what’s causing it. For now? C’est la vie.

Time of day? 11:42pm. Just within the sprint deadline.

Reflections and lessons learnt.

  • Google Cloud Platform is a lot more ‘user’ friendly than AWS. Documentation is super. Despite no training I was able to find may way around the console a lot easier than I thought I would.

  • Guidance and tutorials can be great, but make sure you are building with current system requirements in mind - “It's not what you don't know that kills you, it's what you know for sure that ain't true.”

  • It IS possible to self host a website for less than a cup of coffee per month. Total project costs thus far? $0.

  • Explaining to my partner what ‘ssh’ing is and why my computer screen “looks like the matrix” is beyond the powers of any mere mortal - but I appreciate the support anyway.

  • Most importantly, sometimes it is quicker to cut your losses and start from scratch than try to fix broken.

Previous
Previous

Ad-free internet with a (headless) Raspberry Pi