Host WordPress website on Azure and Connect to Custom Domain

Host WordPress website on Azure and Connect to Custom Domain

In this blog, we are going to create and host a WordPress website on Azure using WordPress Bitnami stack and add the custom domain to it.

Introduction

WordPress is one of the world’s most popular web publishing platforms for building blogs and websites. From blogging to e-commerce to business and portfolio websites, WordPress is a versatile CMS. Designed with usability and flexibility in mind, WordPress is a great solution for both large and small websites.

There are different ways of hosting a WordPress site on Microsoft Azure. In this blog, we are going to use the Bitnami stack where we will use Bitnami WordPress pre-configured Ready-to-Run Image.

Create a Virtual Machine

First login to your Azure Portal and click on Create a resource.

Host WordPress website on Azure and Connect to Custom Domain-min

Search for ‘wordpress’ and hit Enter.

Host WordPress website on Azure and Connect to Custom Domain Awan Shrestha-min

Search for WordPress Certified by Bitnami and click on it.

Host WordPress website on Azure and Connect to Custom Domain Awan Shrestha (2)-min

Then hit Create.

After that, fill out some basic information. Choose your Subscription and resource group. Create a new resource group if you don’t have any. Then your VM name, region, machine size and your username and password.

Host WordPress website on Azure and Connect to Custom Domain (2)-min

Then click on Review + create. If it is still asking for some details, fill that and hit Create.

Host WordPress website on Azure and Connect to Custom Domain (3)-min

After the installation, Go to the resource and under Essentials, you can see the Public IP address.
Copy that and open it on your browser.

Host WordPress website on Azure and Connect to Custom Domain (4)-min

Just a few clicks and now you have your WordPress site on Azure.

Host WordPress website on Azure and Connect to Custom Domain (7)-min

Access to WordPress Admin Dashboard

To access the WordPress Admin Dashboard, go to ‘http://your-public-IP-address/wp-login.php‘. Eg: http://40.114.255.238/wp-login.php

Now for username, the default username if ‘user‘.

And for password, in your Azure VM Dashboard, go to Boot diagnostics.

Host WordPress website on Azure and Connect to Custom Domain (1)-min

Click on Serial log and once it loads, click somewhere on your log. Then press ‘CTRL + F‘ and search for ‘password‘. Search for next match until you find something like “Setting Bitnami application password to ‘************’“.

The ‘************‘ is your WordPress Admin password.

In this way you can access your WordPress Admin Dashboard.

Host WordPress website on Azure and Connect to Custom Domain (6)-min

Connect to Virtual Machine

Now to connect to the virtual machine in Azure, there are different ways. In this blog, we are going to use the simple way via terminal.

To work with commands, we can use any SSH clients like PuTTY, KiTTY, Xshell 5, Git Bash, etc. Here I am going to use Git Bash.

Open Git Bash and enter the ssh command:

 ssh username@DNSLabel

For example here, I had used ‘myuser‘ as username and my public IP address is 40.114.255.238.

So, I will use:

ssh myuser@40.114.255.238
Host WordPress website on Azure and Connect to Custom Domain (9)-min

Enter the password and you have connection with your VM.

Host WordPress website on Azure and Connect to Custom Domain (10)-min

Remove the Bitnami Badge from Azure WordPress

Since now, we have connection with our VM, one thing we can do is to remove the Bitnami badge which appears on bottom right of our site.

To remove the Bitnami badge, simply use the command below, while you have connection with your VM.

sudo /opt/bitnami/apps/wordpress/bnconfig --disable_banner 1

Refresh the page and the badge should be gone now.

Add Custom Domain to the VM

Now of course we cannot tell our user to type the public IP address, 40.114.255.238, every time to visit our website. So, to add the custom domain to your VM, we will be using CNAME record here.

If you want to know more about how domain names resolves to IP address, please check out this post on How the Web Works.

Now from your resource group, choose the resource group where your vm is. In our case it is ‘vm‘.
Then choose the Public IP Address.

Host WordPress website on Azure and Connect to Custom Domain Cname-min

Go to Settings, then inside that, Configuration.
In the ‘DNS name label (optional)‘ section, type a unique name and if it is available, hit Save.

Host WordPress website on Azure-min

So, now your DNS name label will be ChosenName.VMLocation.cloudapp.azure.com. Meaning, you can access your website using this URL.

Host WordPress website on Azure and Connect to Custom Domain Cname (2)-min

In my case, I have used the name mywpwebsite. And my VM location is west Europe. Thus now I can access my site via the URL : http://mywpwebsite.westeurope.cloudapp.azure.com/

Now all we need to do is align our custom domain name with this DNS name label. Go to your DNS provider site and manage DNS settings. Fill the fields as:

Host WordPress website on Azure and Connect to Custom Domain Cname (22)-min

Save the DNS settings and you are all set.

You should be able to access your VM using your custom domain name.

Leave a Comment

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