One of the essential steps you need to do after deploying WordPress on Google Cloud Platform (GCP) is setting up a domain name.
In my past tutorial, you learned How to Install and Setup WordPress on Google Cloud. After successful installation of WordPress, you can see your site is live and running, but an External IP address appears in the site address section instead of domain name. You need to replace that External IP address with your domain
in this post, I’ll show you complete step by step process to set up a custom domain on the Google Cloud Console.
Let’s get started!
Steps to Set Up a domain on Google Cloud Platform
Register your domain or Login into your domain provider account
Choosing the right domain name for your site may take time but make sure it should be simple and memorable. Once you have decided your domain name, then you can register your domain with any domain provider like Namecheap, GoDaddy, BigRock, etc. So, register your domain or if you already have your domain then login into your domain provider account.
Log in to the Google Cloud Console
Visit console.cloud.google.com and then just login into your Google Cloud account. Once you sign in to your GCP account, then you can see your Google Cloud Console Dashboard like the following screenshot.
Enable the Cloud DNS API on GCP
Now at Google Cloud Console Dashboard section, you can see the search bar. Type there ” Google Cloud DND API ” and then hit enter to search. You will able to see an image like below screenshot. You need to click on the Enable button to enable cloud DNS API.
Create a Cloud DNS Zone
After enabling Google Cloud DNS API, click on the Navigation Menu and then under the Networking section, you can see the Network Services option. Click there and then select Cloud DNS.Once you enter on Cloud DNS section, you will see Create Zone option which lets you define your namespace, and you can create public or private zones.Now you need to enter the name of your website in the Zone Name section, and your website’s root domain name in the DNS Name section. After that, you need to click on the Create button. In this section, you can select your Zone type also, i.e., Private or Public[ Note – A private DNS zone contains DNS records that are only visible internally within your GCP network(s), and A public zone is visible to the internet.]
Add DNS Records (Setting Up A Record)
After DNS Zone creation, click on the link “ADD RECORD SET” which will appear on the next page. Now follow my steps to fill details for this page.DNS Name – Leave this part cause you are already written this part earlier. Just make sure it’s written like this format .yourdomain.com. (note the leading and trailing dots)Resource Record Type – ATTL and TTL Unit – Leave them default (No change Required)IPv4 Address – This field is for host’s numeric IP address, in dotted decimal format. Enter here the External IP address of your site. You can find it by clicking the Navigation Menu > Compute Engine > VM Instances > External IP.
Add DNS Records (Setting Up CNAME Record)
After A Record set up, follow my steps below to add CNAME Record for your sub domain.DNS Name – Write Down there your Sub-domain. In my case, it’s wwwResource Record Type – Click the link and select CNAMETTL and TTL Unit – Leave them default (No change Required)Canonical Name – In this field enter your domain (Example – mydomain.com)
Configure NS Record in Your Domain Provider
After setting up DNS Record, at your Zone Details section, you will see 4 NS Records generated automatically, which you need to add with your domain provider.Now you need you to visit and sign in into your domain provider account. In this tutorial, my domain provider is GoDaddy. However, the process will be the same/similar for all domain name providers. Follow my below Steps to Configure Nameservers with your Domain Provider.After login to the domain provider account, you will see My Products page where your registered domain and settings like Add Privacy, DNS, Manage will be displayed like the given image. Now click on the DNS link for DNS Management. In this page, you will see the Nameservers option. Now click on the Change button and then choose Custom option to add those NS records which you received on Google Cloud Zone Details Section. After adding these NS Records, click on Save button to finish the setup.
Congratulations! You’re done setting up your custom domain with Google Cloud Platform.
Now type your website on any web browser and you will be able to see your WordPress website live. If you can’t see your website, don’t panic. Any changes made to your domain nameservers (DNS) might not reflect immediately. It could take up to 24 hours, so wait for some hours and try again later.
However, only pointing a domain with Google Cloud Server isn’t enough. We need to do a few more changes for proper domain configuration, like Static IP address Configuration on GCP and Domain setup for CMS, to prevent access via IP address.
Reserve and Configure a Static IP address on GCP
I hope that before domain set up, you already reserved and configured static IP on GCP. If you missed the step, then learn here – How to Configure and Reserve a Static IP address on VM Instance of Google Cloud Platform. This set up is very important cause at Google Cloud, VM Instances are launched with an Ephemeral IP address by default, which means this IP address changes every time whenever the server is stopped or restarted. That’s why to prevent our website from technical errors, we need to reserve a Static IP address instated of the default IP address.
Domain setup for CMS
After setting up your domain on Google cloud Server, you need to configure your domain name your CMS so that it can works properly. In our case, we are using WordPress as our CMS. So here you can find – How to Configure a Domain for WordPress on Google Cloud. The process will be similar for other CMS. So don’t worry if you are using a different CMS platform.
So in this tutorial, you learned how to point your domain on Google Cloud. If you have any questions regarding this tutorial, then feel free to let me know by commenting below, and I’ll get back you as soon possible.