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 Bitnami 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 a 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
Navigate to Compute Engine –> VM Instances then click on the SSH button to connect to your WordPress installation.
Once connected via SSH, connect as a root user and open your wp-config.php file in the nano editor.
sudo -i then nano /opt/bitnami/apps/wordpress/htdocs/wp-config.php
Replace your SiteURL and HomeURL definitions as shown below.
REPLACE THIS: define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/'); define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/'); WITH: define('WP_HOME','http://yoursite.com'); define('WP_SITEURL','http://yoursite.com');
Remember to replace “yoursite.com” with either the www. or non-www. version of your domain name
That’s it! Your domain name is now pointing to your Google Cloud website!
If you have any questions about installing WordPress in Google Cloud? Ask away in the comments section below.