How to host a WordPress site on Google Cloud Platform

This post will teach you everything I learned about how to host a WordPress site on Google Cloud. Recently I switched the hosting of this site from GoDaddy to Google Cloud. All in all I think it’s been successful and I intend migrating other sites I host over here eventually as well. It definitely threw up a few little fishhooks, some specific to WordPress, that I needed to figure out.

These included:

  • Configuring the robots.txt file
  • Resolving the lack of SMTP support
  • Finding an alternate email host
  • Configuring the DNS.

Server room

What services like GoDaddy do well is make stuff work without you having to know a whole lot about how and why it works. You pay for that, of course, and some people don’t necessarily want to. Google Cloud uses a pay for what you use model and includes a free tier that will suffice for a small, lower traffic website.

This post runs through everything I did to migrate the site and get it working. It calls out the issues that needed solving and how I solved them. It’s not necessarily a step-by-step guide but it should point you in the right direction.

Server Instance (VM) Build and WordPress install

First things first, you need to create server instance (otherwise known as a VM, or virtual machine) and install WordPress onto the instance. Google Cloud makes this very easy with their Cloud Launcher tool. Assuming you have already set up your Google Cloud account visit the Cloud Launcher and search for WordPress. There are a few alternatives but I chose the Google Click to Deploy option. Follow through the prompts to automate deployment of a Virtual Machine for you (you can select the size of the VM and the attached disk) and install WordPress onto the VM. Once the process has completed you’ll be given an IP Address to access the basic WordPress site and the credentials to login to the admin panel. Google Cloud deploy new wordpress site

Migration Tool

If you are migrating an existing site you need to copy the site files from the old host to the new. There is no shortage of tools to do this and I used a plugin called All-in-One WP Migration. You need to install this on both the existing site and the new one. The free version allows you to download the migration file to your computer and then upload it to the new site. There is a paid option that allows you to use Dropbox, Google Drive, Onedrive etc. but I couldn’t see the point of paying $99 when I could just do it for free via my own computer.

When you import the migration file to the new host your admin credentials will be the same as the legacy site. Make sure you know your credentials before performing the migration or you won’t be able to access the migrated site.Site migration dialog

Once you’ve completed the migration, you need to configure the permalinks structure of the site. I recommend once you do this to check any internal links to make sure they are still pointing where you need them to.

Note – At this point the site is live, however only accessible via the IP address No domain name configuration has been completed. When you are ready to point your domain name to the site, follow these instructions to configure your DNS with Google Cloud DNS service.

No SMTP on Google Cloud Compute

Google Cloud Compute Engine instances do not allow outbound connections on ports 25, 465 or 587. These are the default outbound SMTP ports. This will break any functionality that requires your site to send an email e.g. forms. Google offers advice on what you can do to get around this limitation here.

My recommendation is to use Sendgrid. I tried Mailgun and Mailjet but wasn’t able to get them working like I wanted, particularly when hosting my domain email somewhere else. If you visit the Sendgrid website you won’t see any free tier available for you to sign-up for however this can be accessed via Google Cloud. Choosing Sendgrid from the Cloud Launcher allows you to sign up for a free account that can send up to 12,000 emails each month.

Sign up to Sendgrid, install the Sendgrid plugin to your site, generate and insert your Sendgrid API key in the plugin settings. It should just work – at least it did for me!


This was the most perplexing issue but I got there in the end. As far as I can tell, Google Cloud replaces any robots.txt file with their own and it disallows all search engines. This means Google, Bing, Yahoo et al can’t crawl your site.

Replacing the robots.txt file with your own won’t work – Google seemed to detect this and switch it back. You can however edit their robots.txt file in place.There is a full description of what to do here.

I don’t prefer the robots.txt content recommended in their post. My suggested robots.txt file is as follows. This should work for most WordPress sites.

User-agent: *
Disallow: /wp-admin/
Allow: /wpadmin/admin-ajax.php
Disallow: /wp-includes
Allow: /wp-includes/js/
Allow: wp-includes/images/
Disallow: /trackback/
Disallow: /wp-login.php
Disallow: /wp-register.php

Alternatively, the Yoast SEO plugin also allows you to edit your robots.txt file in place.

Don’t forget to configure Google Search Console and any other Webmaster Tools services you want to use. It pays to submit your sitemaps to them to ensure they are crawling your site effectively. This is also a good way to test your robots.txt configuration to make sure it’s not blocking anything unnecessarily.

Email Hosting

The final problem that needed solving was how to host my email. Sure, I could keep pointing my MX records at GoDaddy but the point of this exercise is to move away from their platform. I’m getting my hosting for free so it would be a shame not to do the same with email. There are plenty of options if you don’t mind paying but Zoho have a free email hosting tier. I’ve been using this for several months now and it works just fine. The plan includes 1GB of storage and allows for one domain name. They also have instructions for the necessary DNS configuration settings you’ll need to add to Google Cloud DNS.

I hope you find this guide useful. Leave a comment below if you have any questions about how to get yourself set up!

  7 Replies to “How to host a WordPress site on Google Cloud Platform”

  1. Marge
    August 25, 2017 at 12:12 pm

    Why did you decide to move your WordPress sites to Google hosting? There are so many excellent WordPress hosting vendors that make developing and deploying a website easy. What is the advantage of using Google for hosting?

    • August 25, 2017 at 12:14 pm

      Experimentation mostly, and wanting to DIY things a little. I like to know how things work.

  2. dhruv pandit
    November 12, 2017 at 7:55 pm

    is GCP free for life will able to host a wordpress site (with low traffic)?

    my current host has more downtime and i can’t afford a pro hosting right now, will hosting my site on GCP will be SEO friendly?

    • November 12, 2017 at 11:33 pm

      Don’t know the answer to your first question sorry. In terms of being SEO friendly, I’m not sure if it will make any difference.

  3. lumper5
    January 19, 2018 at 12:41 pm

    As a related tip, the robots.txt file issue is avoided when you install WP from scratch yourself instead of using the Google Cloud Launcher. It takes a bit longer, but you avoid the issue of Google detecting your robots.txt and replacing it. You have to create a robots.txt from scratch. I find your discussion of SendGrid helpful and I used it to get mail flowing on my VM self-install.

  4. March 23, 2018 at 2:35 pm

    whats the difference in cost of godaddy and google?

    • March 23, 2018 at 3:10 pm

      It all depends on what google cloud services you’d need to use vs. what hosting package you get from GoDaddy. Google Cloud gives you a $300 credit to use over your first year, so it’s basically free to start with. They also have free tiers for some services so if you can stay within that it’ll be free as long as they maintain the service.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.