This is part 2 of a three-part guide to setting up and configuring WordPress hosted on Google Cloud Platform and registered with a Google Domain URL. Readers should make sure their WordPress instance is running and behaving properly using GCP and have WordPress admin access before attempting this guide. You can read part 1 here.
To prevent bulking of a single article, I separated this holistic guide into three separate parts. Feel free to jump to the next article when you are done with this one. For your convenience, the guides are outlined below:
Table of Contents
Benefits of Using Google Domains
Google Domains is a relatively new service compared to other hosting services such as GoDaddy and HostGator which provides some features that are convenient for regular Google account holders. While discounts and promotions are seldom for Google Domains (this makes Google Domains usually more expensive than other hosting services at the most basic level), it comes with many options included in the base price. You can read about the features on the Google Domains landing page, but the two good selling points that come packaged are the masking of WHOIS information as well as the domains being hosted behind Google’s fast and reliable data infrastructure. Although I haven’t used other domain hosting platforms, Google Domains’s UI is also very straightforward and simple, making things like DNS setting very easy.
Continue on for the step-by-step guide.
Pre-Requisites
- GCP account with running WordPress instance, and administrator console access.
- Have your instance IP address on hand – you will need it to configure DNS records.
- Google Domains, with a domain purchased and ready for setup:
Setting IP Address of VM Instance to Static
Make sure that your instance is always assigned the same IP address. Failure to do will may result in GCP assigning the instance a different IP, which will break the DNS configurations you will make further down this guide and result in the domain not being able to resolve to your WordPress instance. This is a rather important step that should not be overlooked.
To set your instance to static, open up your GCP account and set it to your WordPress site’s project. At the center of the header navigation is a search bar – type in “External IP addresses” and select the “External IP addresses – VPC Network” option:
Set the IP address to static and confirm in the popup window that appears. Enter a name for the external IP address – it can be anything you like:
Configuring Google Cloud Platform’s Cloud DNS Settings
At the center of the header navigation is a search bar – type in “Cloud DNS” and select the “Cloud DNS – Network Services” option:
Since I already created my DNS zone, an entry is visible as shown. For you, however, a prompt may appear for you in the middle of the window to create a new zone. If so, click on that button, or refer to image below to start setting a new DNS zone.
You will be brought to the following screen:
- Zone Name can be anything you want as long as it complies with the naming convention (A prompt will shout at you if you give a bad name!).
- DNS name should be the domain you registered with Google Domains (in this case, example123.net). Do not include “http://” nor “www.” here.
- Click Create
Now you will add TWO record sets – one for linking the domain to your instance’s IP address, and another for mapping www. subdomain.
Start with the “A” record.
- Make sure Resource Record Type is “A” (should be default).
- For IPv4 Address, set this equal to your WordPress instance’s IP Address.
- Click Create.
You should return back to the DNS Records setting page, and a new entry for “A” record should now be visible. To configure the “CNAME” record, Follow Figure 2-5 and click on “Add Record Set” again.
- For DNS Name, add “www” to the field as shown above.
- Set Resource Record Type to “CNAME”.
- For Canonical name, set this equal to your Google Domains’s URL.
- Click Create.
You should now have a total of FOUR entries in the Zone Details page: “A”, “NS”, “SOA”, and “CNAME”.
One piece of information you must note from here are the NS values, highlighted below:
GCP and Google Domains use DIFFERENT name servers, and so we will need to override the Google Domains’s DNS settings to reflect the values shown here. How to do that is detailed in the next section.
Configuring Google Domain’s Cloud DNS Settings
On the same or separate browser window, navigate to Google Domains Console and verify that your domain exists in the dashboard.
Under the DNS column, click on the icon corresponding to the domain you wish to change DNS configurations for:
Select “Use custom name servers” and fill in four entries corresponding to the DNS name servers you found in the GCP Cloud DNS page (refer to Figure 2-7). Click Save to save the settings. When you’re done, scroll down until you see the section labelled “Custom resource records”. Here you will make the same settings you did on the GCP Cloud DNS settings section. Refer to the figure below for guidelines – note that “@” is synonymous to your domain name.
** There may be a warning that shows up stating “It looks like you’ve changed your name servers…”. You may ignore it.
Once you are done, take a 5-minute breather (grab a coffee!) and then you may optionally check to see whether your domain is registered successfully across DNS servers worldwide. If everything goes smoothly then you should see your domain being registered to the IP address of your WordPress site and reflected in the DNS Checker results. The site I use is DNS Checker.
Configuring SiteURL and Host Name on WordPress Admin Console
On another browser window, navigate to “http://##DOMAIN_NAME##.com/wp-admin/options-general.php” and provide your admin credentials if necessary. You should be brought to the General Settings page and, if you deployed the Click-to-Deploy version of WordPress, you should see the two fields “WordPress Address (URL)” and “Site Address (URL)“. Fill it with your registered domain (see below for reference), and click “Save Changes” at the bottom of the page.
Confirming Domain is Successfully Registered
Test that you are able to connect to your WordPress site by trying any or all of the following combinations:
- domain.com
- www.domain.com
- http://domain.com
- http://www.domain.com
If you could successfully navigate to your site via the options above, congratulations, you have finished registering your Google domain with your GCP WordPress instance!
Next Steps
Now everything is set and ready to go for online readers to navigate to your site. However, one problems remains which is that your WordPress site is not secured under the HTTPS protocol yet. To do that, you will need to to create and register a certificate on your WordPress VM instance and configure Apache settings to redirect all HTTP traffic to HTTPS. Having HTTPS provides a security advantage, SEO advantage, and gives readers piece of mind knowing that your site is committed to a decent level of security.