A domain name is like a street address that directs people to your website’s location. This tutorial will show you the easiest way is to point your domain name to your (Click to Deploy) version of the WordPress site on GCP.
Prerequisite: Before starting this tutorial, you should’ve already purchased a domain name and have set up WordPress on Google Cloud.
1. Create a DNS zone
Log in to the Google Cloud Platform dashboard and Head over to Network Services -> Cloud DNS.
In the resulting screen, Click on Create Zone.
Add the name of your website in the Zone Name field, and your domain name in the DNS Name field. Click the Create button.
Locate your IPv4 address by navigating to Compute Engine -> VM Instances and Make note of External IP as you need it in the next step.
2. Add DNS Records
After creating your zone, click on the Add Record Set. Then create an “A” record.
- In the Resource Record Type field, select “A”.
- In the IPv4 Address field, enter your IPv4 address.
Next, create a CNAME record.
- In the DNS Name field enter www.
- In the Resource Record Type select CNAME.
- Enter your domain name in Canonical name field.
Make note of four NS records as you need them in the next step.
3. Add an NS record
Add the NS records in Control panel of Domain Provider. In this example, Godaddy is used as the domain name provider, however, the process will be similar for all domain name providers.
- Log into your GoDaddy Account Manager.
- Locate the domain, then select Manage DNS
- In the Nameserver settings select Custom, then click the Edit Name Servers link.
- Add the data you got in step 2 and click save to finalize the changes.
4. Edit WordPress URLs
Enter the preferred URL for your website in the URL fields. This can either be at www.yourdomain.com or at yourdomain.com. The important thing is to select and stick to a preferred version.
To change your preferred WordPress URLs, navigate from your WordPress dashboard to Settings -> General.
Lastly, make sure that you check the permalink structure of your website. After changing your domain name settings, this setting often gets corrupted. By going to Settings -> Permalinks, you can access your permalink settings.
That’s it! Your domain name is now pointing to your WordPress Site on Google Cloud!