So you wanna start a blog, but you’re not sure where to start. Maybe you don’t have much of a budget for hosting, or you’re not ready to drop hundreds of dollars a year on your blog yet.

Never fear. You can deploy a WordPress blog for little to nothing by taking advantage of free cloud resources available to anyone. No ads, jacked up renewal fees, or other funny business.

In this comprehensive tutorial, I’ll be showing you how to launch your blog in Google Cloud Platform (GCP), but the process only differs slightly if you’d prefer to use Amazon Web Services, Microsoft Azure or IBM Cloud.

Prerequisites

Before we get started, this guide assumes you have:

  • Purchased a domain — Need one? I recommend Hover.com
  • Created a Cloudflare account and added your domain — Optional, but highly recommended. Learn more here.
  • Created a Google Cloud Platform account — Sign up for free here.

The cloud vs. traditional hosting

Why would you want to host your blog in the cloud? Traditional web hosting can be had starting at $2.99 a month, right?

Hosting your blog in the cloud has a couple of advantages. For one, you only pay for what you need. Cloud hosting is paid by the minute, which means there is really no commitment. With most web hosts, you pay annually regardless of whether you’re actually using the service.

Most cloud providers have generous free tiers so customers can try out the service or host smaller projects. We're going to be taking advantage of this in this guide.

Cloud hosting does have its pitfalls. Perhaps the biggest is the lack of customer support. If you run into trouble, or can’t figure something out, don’t count on the cloud provider for help. You'll have to rely on a Google search — or more likely a few dozen — to find any answers to your problems.

With that said, hosting your blog in the cloud is easier than it looks, and in this tutorial, I'll show you exactly how to do it.

Deploying your blog

We're going to start by deploying our WordPress blog in what's called a virtual machine in Google Compute Engine. While this may sound daunting, don't worry. WordPress is so popular that the process is almost completely automated.

Once you've logged into the Google Cloud Platform console, navigate to the sidebar and click on Marketplace.

From the Marketplace, search for “WordPress Virtual Machine.” The first entry should be the one we’re looking for. Don’t worry if it says the estimated cost is $13.61 a month, we’ll fix that in a second.

Click launch to start the installation wizard.

On the next screen, we’ll need to make a few adjustments to the default deployment.

Start by entering a name for your blog and select which data center you’d like to use.

Next, you’ll want to change the machine type to F1 Micro. This is the smallest instance Google offers and more importantly the first instance is free.

Finally, you’ll want to check allow HTTP and HTTPS traffic from the internet.

Once you've completed these steps, click deploy. After a few minutes, your WordPress server should be up and running, and you should see your log-in credentials under the Deployment Manager. Be sure to take note of relevant usernames, passwords, as well as your IP address.

Setting a static IP

Before we can continue, we need to set a static IP for your blog. By default, GCP assigns an ephemeral IP address to your blog, which will change any time it's restarted.

Thankfully, this step is easy. Just head over to the sidebar and scroll down to VPC Network and select External IP addresses.

From there, select your virtual machine and change the type from ephemeral to static. From there, assign a name and click reserve.

Congrats, now we have a static IP.

Create the swap

The next step may look intimidating if you haven’t ever used a Linux terminal, but you can do it.

What is a swapfile and how do you create one?

Since we’re using Google’s smallest virtual machine, we don’t have a lot of resources to work with. A swapfile helps absorb sudden spikes in traffic so when your first blog post goes viral, your site doesn’t crash.

Creating a swapfile is pretty easy, but it does mean typing a few commands into the terminal and editing a configuration file.

To get started, select the Deployment Manager from the sidebar and click the SSH button on the right side of the screen. A new window with a terminal interface will appear. From here, we’ll need to enter a few commands.

The first three commands will update the server and install a basic resource monitoring tool.

$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get install htop

Next, we’re going to create the swapfile. Enter the following lines one by one in the terminal and press enter after each.

$ sudo fallocate -l 1G /swapfile
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
$ sudo chmod 600 /swapfile
$ sudo swapon /swapfile

Great work, you’ve created the swapfile. But we’re not done yet. We need to make sure that swap is enabled if we ever have to restart the virtual machine. To do this, we need to add a line of code to a configuration file. Open the file by typing the following command into the terminal.

$ sudo nano /etc/fstab

Next, paste the following at the end of the file and press Control O to save and then Control X to exit.

/swapfile swap swap defaults 0 0

To test if the swapfile is working, enter the following command.

$ htop

You should see a bar toward the top of the screen that shows a gigabyte of available swap. Yay, the hardest part is done!

Configure your DNS settings

Head back to the Deployment Manager in GCP and write down your your static IP address, we’ll need this in a minute.

In order to get our domain pointed at your WordPress blog, you'll need to configure your domain's DNS settings. We’ll be using Cloudflare’s free DNS service for this step. In addition to providing DNS management, the service adds a layer of protection against attacks and can significantly speed up your site. But if you’ve opted to use your domain registrar's service, the process should be almost identical.

We'll be creating two DNS records. The first will point to our blog running in GCP, while the second will ensure that anyone typing "www." before your domain doesn't get an error page.

Type Name Content TTL Proxy
A YOUR_DOMAIN.COM YOUR_STATIC_IP Auto Proxied
CNAME www YOUR_DOMAIN.COM Auto Proxied

Give it a test

If you've configured your DNS records correctly, you should be able to reach your WordPress blog by typing your domain name into your browser.

Note: it may take a few minutes for the change to take effect depending on which DNS provider you're using.

Configure WordPress

Now that you've got everything configured on the backend, you can fire up WordPress and start configuring your new blog.

Start by logging into the admin console by visiting YOURDOMAIN.COM/wp-admin . You can find your username and password in the Deployment Manager in GCP.

From there, scroll down to General Settings and update your site title, site description, WP and site URLs, and timezone. Once complete, hit save.

Securing your blog

We're almost done, I promise. Before you start your first post, we need to lock down your site.

You might have noticed the little message in your address bar warning you that your blog is "Not Secure." That's because we need an SSL certificate.

The easiest way to solve this is to use Cloudflare's edge certificate. It's not perfect, but for most blogs where you're not collecting sensitive information from your readers, it's good enough. More importantly, it's really easy to set up.

Start by heading back to Cloudflare. Under the SSL/TLS tab, change your encryption mode to flexible. This will ensure all traffic from the browser to Cloudflare is encrypted.

Next, we need to make sure anyone who types HTTP instead of HTTPS into their browser is redirected to the secure connection. To do this, head over to the Edge Certificates tab under SSL/TLS and turn on Always Use HTTPS.

Let'sEncrypt with Certbot

If you're not using Cloudflare, or you'd prefer to have end-to-end encryption, you can use Certbot to issue a Let'sEncrypt SSL certificate. Unfortunately, this is beyond the scope of this post, but Certbot has plenty of excellent tutorials to guide you through the process. You can learn more about configuring Certbot here.

Note: in order to properly configure Certbot, you'll need to know a few details about your WordPress deployment, namely what web server and operating system it's running on. If you're using the default WordPress image on the GCP marketplace, you'll be using Apache on Debian 10 Buster.

Helpful resources if you run into trouble

We covered a lot in this tutorial, so please let me know if you got stuck at any step along the way. I'm happy to answer your questions and update this post with additional details.

If you need help with something not covered in this post, I recommend you check out these excellent resources:

You did it!

Congratulations, you've successfully launched a WordPress blog into the cloud. All your hard work has paid off and now it's time to celebrate by writing your first blog post.

If you found this guide useful, please take a moment to leave a comment below. I'd love to hear how your experience went, and if you ran into any trouble along the way.

More to come

This post is part of a larger series on blogging that will be released over the next few weeks. Find all the posts in the series at the link below.

What do you think? Share your thoughts in the comments below:

  • Where do you host your blog?
  • Do you prefer the simplicity of managed hosting or the flexibility of the cloud?
  • Would you like to see guides for other cloud providers like Microsoft Azure or Amazon Web Services?
  • How about other platforms like Ghost, Joomla or Drupal?

If you liked this post, please consider becoming a member. You'll get access to all of my posts weeks before they go public and get access to the comments section. Just enter your email in the form below, it's that simple.