How to Deploy a Static Website to AWS EC2 with Custom Domain
For many developers, business owners, and IT teams, hosting a static website on AWS EC2 with a custom domain offers unmatched flexibility, scalability, and performance. However, setting up the architecture, networking configurations, and domain routing can feel intimidating without a clear roadmap. In this article, we’ll take you through a detailed, step-by-step guide to deploy a static website on AWS EC2, configure a Virtual Private Cloud (VPC), and link it to a custom domain purchased from GoDaddy.
Whether you’re a seasoned developer or a business owner looking to understand the backend of your hosting infrastructure, this comprehensive guide will help you navigate the process effortlessly.
Introduction: Why Choose AWS EC2 for Static Websites?
AWS EC2 (Elastic Compute Cloud) is a popular choice for hosting static websites due to its scalability, reliability, and extensive customization options. By deploying on AWS EC2, you gain access to advanced features such as:
- High uptime and performance.
- Customizable compute instances to match your website’s traffic needs.
- Integration with services like AWS Route 53 for seamless domain management.
In this guide, we’ll walk through:
- Setting up the AWS architecture.
- Deploying a static website.
- Configuring a custom domain using GoDaddy with AWS Route 53.
sbb-itb-59e1987
Step-by-Step Guide to Deploying a Static Website on AWS EC2
1. Setting Up the Networking Architecture
The foundation for deploying a static website on AWS begins with configuring the networking components of your infrastructure. Follow these steps:
Step 1.1: Create a Virtual Private Cloud (VPC)
- Log in to your AWS Management Console and navigate to the VPC Dashboard.
- Create a new VPC with a unique name (e.g.,
myVPC) and an IPv4 CIDR block (e.g.,10.0.0.0/21). - Confirm successful creation of the VPC.
Step 1.2: Configure a Public Subnet
- Inside your VPC, create a public subnet with a smaller CIDR block (e.g.,
10.0.0.0/24). - Assign the subnet to an availability zone (e.g.,
us-east-1a).
Step 1.3: Attach an Internet Gateway
- Create and name an Internet Gateway (IGW) (e.g.,
myIGW). - Attach the gateway to your VPC.
Step 1.4: Create a Route Table
- Create a route table for your VPC and associate it with the public subnet.
- Add a rule to the route table to direct all traffic (
0.0.0.0/0) to the Internet Gateway.
By completing these steps, you’ve established your AWS networking foundation, ensuring your resources can communicate with the internet.
2. Launching and Configuring an Amazon EC2 Instance
With your networking configuration in place, the next step is launching the EC2 instance and preparing it to host your website.
Step 2.1: Launch the EC2 Instance
- Go to the EC2 Dashboard and click Launch Instance.
- Configure the following:
- Instance Name:
static-website-instance. - Operating System: Ubuntu (choose the standard Amazon Machine Image).
- Instance Type: Select a lightweight option like
t2.micro. - Networking: Attach it to your VPC and public subnet (created earlier). Enable the auto-assign public IP option.
- Security Groups: Define inbound rules for:
- SSH (port 22) to allow remote access.
- HTTP (port 80) to serve web traffic.
- Instance Name:
- Generate and download a key pair for SSH access.
Step 2.2: Install Apache Web Server
- SSH into the instance via your terminal or AWS Cloud Shell.
- Update the instance:
sudo apt update -y - Install the Apache web server:
sudo apt install apache2 -y - Start and enable the web server:
sudo systemctl start apache2 sudo systemctl enable apache2
You can now verify that Apache is up and running by accessing the public IP of the EC2 instance in your browser (e.g., http://<YourPublicIP>). The default Apache welcome page should display.
3. Deploying the Static Website Files
With the Apache server set up, you’re ready to upload your static website files.
- Clone your static website’s repository (e.g., from GitHub):
git clone <repository-url> - Navigate to the Apache root directory:
cd /var/www/html - Remove the default
index.htmlfile:sudo rm index.html - Move your cloned website files into the directory:
sudo mv /path-to-cloned-repo/* /var/www/html - Refresh the public IP URL in your browser. Your static website should now be live!
4. Configuring a Custom Domain with AWS Route 53
Adding a custom domain provides professionalism and credibility. This section shows how to link your GoDaddy domain to AWS Route 53.
Step 4.1: Create a Hosted Zone
- In the AWS Route 53 Dashboard, create a new public hosted zone for your domain (e.g.,
example.com). - AWS will generate a set of four name servers (NS).
Step 4.2: Update Name Servers in GoDaddy
- Log in to your GoDaddy account and navigate to the DNS settings of your domain.
- Replace GoDaddy’s default name servers with the AWS Route 53 name servers.
- Save the changes (DNS propagation may take 5–30 minutes or longer).
Step 4.3: Configure an A Record
- In the Route 53 hosted zone, create an A record.
- Point the record to your EC2 instance’s public IP address.
Once DNS propagation completes, you’ll be able to access your website using your domain (e.g., http://example.com).
Key Takeaways
- AWS Architecture Setup: Configuring a VPC, subnet, internet gateway, and route table ensures your infrastructure can handle traffic securely and efficiently.
- Apache for Static Websites: Deploying a static website is seamless with Apache, a lightweight and reliable web server.
- Custom Domains with Route 53: By updating name servers and creating DNS records, you can link a GoDaddy-purchased domain to your AWS-hosted website.
- Scalability and Performance: AWS EC2 offers a scalable solution, which can be tailored to match your website’s needs.
Conclusion
Deploying a static website on AWS EC2 with a custom domain may seem complex at first, but breaking it into manageable steps simplifies the process significantly. By following this guide, you’ve built a robust hosting environment that is highly customizable and scalable, ideal for high-traffic websites or mission-critical applications.
While this tutorial covers the basics of deployment, there’s room for further optimization, such as adding SSL/TLS encryption via AWS Certificate Manager to secure your website. As your hosting needs evolve, AWS provides the tools and flexibility to adapt your infrastructure accordingly.
Source: "Deploy a Static Website on AWS EC2 with Custom Domain (GoDaddy + Route 53)" – vijay giduthuri, YouTube, Aug 30, 2025 – https://www.youtube.com/watch?v=OXenklJPvpE
Use: Embedded for reference. Brief quotes used for commentary/review.