September 23, 2019

Pointing your Domain Name to WordPress on Google Cloud (Bitnami)

Pointing your Domain Name to WordPress on Google Cloud (Bitnami)

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.

Pointing your Domain Name to WordPress on Google Cloud - Cloud Dns

In the resulting screen, Click on Create Zone.

Pointing your Domain Name to WordPress on Google Cloud - 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.

Pointing your Domain Name to WordPress on Google Cloud -Zone Name

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.

Pointing your Domain Name to WordPress on Google Cloud - Copy IPv4 address

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.

Pointing-your-Domain-Name-to-WordPress-on-Google-Cloud -Add a record

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.

Pointing your Domain Name to WordPress on Google Cloud - Add Cname

Make note of four NS records as you need them in the next step.

Pointing your Domain Name to WordPress on Google Cloud

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.

  1. Log into your GoDaddy Account Manager.
  2. Locate the domain, then select Manage DNS
  3. In the Nameserver settings select Custom, then click the Edit Name Servers link.
  4. Add the data you got in step 2 and click save to finalize the changes.

Pointing your Domain Name to WordPress on Google Cloud

4. Edit WordPress URLs

Navigate to Compute Engine> VM Instances then click on the SSH button to connect to your WordPress installation.

Pointing your Domain Name to WordPress on Google Cloud

Once connected via SSH, connect as a root user and open your wp-config.php file in the nano editor.

How-to-Add-a-Custom-Domain-to-your-WordPress-site-on-Google-Cloud
sudo -i

then 
nano /opt/bitnami/apps/wordpress/htdocs/wp-config.php

Replace your SiteURL and HomeURL definitions as shown below.

How to Add a Custom Domain to your WordPress site on Google Cloud

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.

Naffys Mir

I'm Naffys Mir, Programming Geek and Founder of CodersStuff.com. Coders Stuff is a Blog Packed with Loads of High-quality Programming Tutorials and a Ton of Engaging Advice and Insight into Front and Back End Technologies.

View all posts

4 comments

Your email address will not be published. Required fields are marked *