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.
- Configuring the robots.txt file
- Resolving the lack of SMTP support
- Finding an alternate email host
- Configuring the DNS.
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.
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.
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.
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.
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!