Not Accessing Website Hosted on an Apache EC2 Instance with GoDaddy Domain: A Comprehensive Guide
In this article, we will discuss the process of serving a website on an Apache EC2 instance and connecting it to a domain purchased from GoDaddy. We will cover the key concepts, including creating a hosted zone in Route53, configuring Apache, and updating the domain's DNS settings. By the end of this article, you will have a clear understanding of how to serve your website using an Apache EC2 instance and a GoDaddy domain.
Prerequisites
- An AWS account with an EC2 instance running Apache
- A domain name purchased from GoDaddy
Creating a Hosted Zone in Route53
The first step in connecting your GoDaddy domain to your EC2 instance is to create a hosted zone in Route53. A hosted zone is a container for records that you can use to route traffic to your resources.
To create a hosted zone in Route53, follow these steps:
- Sign in to the Route53 console
- Click on "Hosted zones" in the left-hand navigation
- Click on "Create hosted zone"
- Enter your domain name in the "Domain name" field
- Leave the "Type" field set to "Public hosted zone"
- Click on "Create"
Once you have created the hosted zone, you will see four NS records and an SOA record. These records are used to route traffic to your resources.
Configuring Apache on your EC2 Instance
The next step is to configure Apache on your EC2 instance to serve your website. To do this, follow these steps:
- Connect to your EC2 instance using SSH
- Navigate to the Apache configuration directory (/etc/httpd/conf.d)
- Create a new configuration file for your website (e.g. mywebsite.conf)
- Add the following code to the configuration file:
<VirtualHost *:80>
DocumentRoot /var/www/html/mywebsite
ServerName mywebsite.com
ServerAlias www.mywebsite.com
ErrorLog /var/log/httpd/mywebsite_error.log
CustomLog /var/log/httpd/mywebsite_access.log combined
</VirtualHost>
Replace "mywebsite.com" with your domain name and "/var/www/html/mywebsite" with the path to your website's files.
Updating the DNS Settings for your GoDaddy Domain
The final step is to update the DNS settings for your GoDaddy domain to point to your EC2 instance. To do this, follow these steps:
- Sign in to your GoDaddy account
- Click on "My Products" in the top navigation
- Click on "DNS" next to your domain name
- Click on the "Add" button next to "Records"
- Add the following records:
- Type: A, Host: @, Points to: the IP address of your EC2 instance
- Type: CNAME, Host: www, Points to: mywebsite.com
- Type: NS, Host: @, Points to: the four NS records from your Route53 hosted zone
- Type: SOA, Host: @, Points to: the SOA record from your Route53 hosted zone
Once you have added these records, it may take up to 48 hours for the changes to propagate.
- Create a hosted zone in Route53
- Configure Apache on your EC2 instance
- Update the DNS settings for your GoDaddy domain
References
- Amazon Route53: https://aws.amazon.com/route53/
- Apache HTTP Server: https://httpd.apache.org/
- GoDaddy: https://www.godaddy.com/