How to set up a custom domain for your EC2 instance without using Route53
Tags: aws, ec2, webdev, route53
Published: 2019-03-21 03:11:13

---
title: How to set up a custom domain for your EC2 instance without using Route53
published: true
description: A brief tutorial explaining how to add a custom domain address to a replace the public IP of an EC2 instance, without using AWS Route53.
tags: aws, ec2, web-development, route53
series: WordPress via AWS EC2

categories : [Tutorial,Opinion,Discussion]
category: Tutorial
prevPostLink : https://dev.to/maybebored/deploy-a-wordpress-website-using-aws-ec2-the-absolute-beginners-guide-2plf
---

In my [previous post](page.prevPostLink) I explained how to deploy a simple WordPress site using AWS. This post shows how to set up a custom domain to access your site. The default way to access EC2 instances is by typing its IP address (*192.168.0.1*) in a browser. This is great for testing, but when going public with your blog or portfolio website, it makes more sense to have a domain name such as "example.com" instead. You can learn more about [DNS and IP addresses](http://bpastudio.csudh.edu/fac/lpress/471/hout/netech/dns.htm) outside this post.

[AWS Route53](https://aws.amazon.com/route53/) is a web-based domain resolution service, packed with additional features for reliability and scalability. It's easy to use, flexible and great for beginners. However, this post is intended for those (like me) who do not wish to use Route53.

###Step 1 - Set up Elastic IP

![allocate new IP address](https://d1.awsstatic.com/Getting%20Started/launch-an-app/get-a-domain/Getting-Started-EIP1.4e0ed611d18a8bba0c9a97a1bff19595c6b51803.png)

Navigate to EC2 > Network and Security > Elastic IPs on the AWS Management Console and click on allocate new address.

![associate new IP address begin](https://d1.awsstatic.com/Getting%20Started/launch-an-app/get-a-domain/Getting-Started-EIP4.a981d9bbdf876d00aab66ce33c9d0e5b01c50c59.png)

Click "Allocate" on the next screen. You'll see your newly created Elastic IP after confirming. Select this IP > Actions > Associate Address.

![associate new IP address end](https://thepracticaldev.s3.amazonaws.com/i/wm5h2lpd0vf5iygd8rrb.png)

Select your instance from the dropdown and click Associate. You now have an elastic IP address for your EC2 instance. This means you have a static IP that doesn't change even after restarting the instance. This is important to complete our next step.

Verify that you can see your website by navigating to this elastic IP address.

###Step 2 - Update your domain's DNS records to point to your elastic IP


![DNS records](https://thepracticaldev.s3.amazonaws.com/i/brpltr6rk4obrzvznms0.png)

Create [type A DNS record](https://pdrcybersecurity.com/dns-request-types-cheat-sheet/) for your domain, which points to your elastic IP. Without an elastic IP,  we'd have to keep updating this record ever time you restart your AWS instance.

After you create a new DNS record it can take anywhere between 5 minutes to 1 hour, to update. :hourglass_flowing_sand:


###Step 3 - Update EC2 instance's domain settings

Login to your EC2 instance via SSH, then specify your domain name in apps/wordpress/htdocs/wp-config.php file like shown below.

Replace```define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');```
with```define('WP_SITEURL', 'http://DOMAIN/');
define('WP_HOME', 'http://DOMAIN/');```

And that's about it. You should be able to access your WordPress site at your domain address. :tada:

*Let me know what you thought about this article in the comments. I want to improve my writing and help others learn to love tech, the way I did.*