AWS ec2 Website Hosting Setup Guide (How to)

Make sure you have an AWS account. If you don’t, head over to the AWS homepage and click the “Create an AWS Account” button. Don’t worry, the steps are pretty straightforward.

Step 1: Launch an EC2 Instance

Once you’re logged into your AWS account, it’s time to launch your EC2 instance!

  1. Navigate to the EC2 Dashboard and click “Launch Instance.”
  2. You’ll be asked to choose an Amazon Machine Image (AMI). For a basic web server, select “Amazon Linux 2 AMI.”
  3. Next, choose an instance type. For a simple website, a “t2.micro” instance will be more than enough.
  4. Click “Next: Configure Instance Details,” then “Next: Add Storage,” then “Next: Add Tags.” You don’t need to change anything here for now.
  5. Now we’re at the “Configure Security Group” step. This is important for allowing people to view your website. Create a new security group and add a rule for HTTP. The settings should be:
    • Type: HTTP
    • Protocol: TCP
    • Port Range: 80
    • Source: Anywhere (
  6. Click “Review and Launch,” review your instance launch details, then click “Launch.”
  7. A popup will appear asking you to create a new key pair. This is crucial for connecting to your instance securely. Name it something memorable, download the key pair, and then “Launch Instances.”

Great job! You’ve now launched your EC2 instance. Keep that key pair safe and secure, you’ll need it soon.

Step 2: Connect to Your Instance

Now, let’s get connected to your instance.

  1. Head back to the EC2 Dashboard and click on “Instances” on the left.
  2. Select your newly created instance and click “Connect.”
  3. Choose “SSH client” for the connection method. You’ll see a detailed instruction on how to connect. Essentially, you’ll need to open your Terminal (or Command Prompt on Windows), navigate to the folder containing your downloaded key pair, and run a command like:
ssh -i "your-key-pair.pem"

Replace "your-key-pair.pem" and "" with your actual key pair file name and your actual EC2 instance public DNS.

Step 3: Install a Web Server

Once connected, we’ll install Apache, a popular web server software.

Run these commands:

sudo yum update -y
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd

These commands will update your instance, install Apache, and start the server.

Step 4: Create a Simple Web Page

Next, let’s create a basic web page. Navigate to the web server’s root directory and create a new file:

cd /var/www/html/
sudo nano index.html

This will open a text editor. Type your HTML code here, something like:

<!DOCTYPE html>
<h1>Welcome to my AWS EC2 Website!</h1>
<p>This is a simple static webpage hosted on AWS EC2.</p>

Save and close the file by pressing CTRL+X, then Y, then ENTER.

Step 5: Check Out Your Website

Now, open a web browser and type in your EC2 instance’s public DNS followed by the file name in the URL. It should look something like this:


And there you have it! You should see the web page you just created. It’s a simple example, but it’s a start. With AWS EC2, you have the flexibility to host all sorts of websites, apps, and services. Keep exploring and happy coding!


If you want to use a .com domain name then setu dns:

If you want to associate a domain name with your EC2 instance, you’ll need to use Amazon Route 53, AWS’s scalable Domain Name System (DNS) web service. The following steps will guide you on how to use Route 53 to connect your domain name to your website hosted on EC2.

Step 1: Register a Domain

If you haven’t got a domain name already, you can register one through Amazon Route 53. To do this:

  1. From the AWS Management Console, navigate to the Route 53 console.
  2. Click on “Domain Registration.”
  3. Click on “Register Domain.”
  4. Follow the prompts to complete your domain registration.

Step 2: Create a Hosted Zone

A hosted zone is a container of information about how you want to route traffic on the internet for a domain, such as, and all its subdomains (,, etc.).

  1. In the Route 53 console, click on “Hosted zones.”
  2. Click “Create Hosted Zone.”
  3. Enter your domain name and leave the type as “Public Hosted Zone.”
  4. Click “Create.”

Step 3: Create a Record Set

A record set (also known as “Resource Record Set”) tells the Domain Name System how to route traffic for a specific domain.

  1. Click on the name of your hosted zone.
  2. Click “Create Record Set.”
  3. Leave the Name field blank to route traffic to your domain.
  4. For Type, choose “A – IPv4 address.”
  5. For Alias, choose “Yes.”
  6. For Alias Target, enter the public DNS of your EC2 instance (e.g., “”).
  7. Click “Create.”

Step 4: Update the Nameservers for Your Domain

Finally, you’ll need to update the nameservers for your domain to point to the Route 53 hosted zone.

If your domain is registered with Route 53:

  1. In the Route 53 console, click “Registered domains.”
  2. Click on your domain name.
  3. Click “Add or edit name servers.”
  4. Replace the existing nameservers with the ones listed in the NS record in your hosted zone.
  5. Click “Update.”

If your domain is registered with another registrar, you’ll need to log into your account at that registrar and replace the existing nameservers with the ones listed in the NS record in your hosted zone.

And that’s it! It may take some time (up to 48 hours) for these changes to propagate across the internet. Once done, anyone who types your domain name into their browser will be routed to your EC2 instance.


Alternative s3 static hosting

Amazon S3 stands for “Simple Storage Service,” and it’s exactly that – a service where you can store your files in what they call ‘buckets’. So think of it as a big cloud up there holding your buckets of website files!

Here’s how to get your website up and running on S3:

Step 1: Create a Bucket

First off, you’ll need to create a new bucket in S3:

  1. Open the Amazon S3 console in your AWS Management Console.
  2. Click “Create bucket.”
  3. Give your bucket a name – it must be unique across all of Amazon S3. Maybe name it something like “best-website-ever-yourname,” just to keep things humble.
  4. For region, select the region that is closest to where you expect most of your site’s traffic to come from.
  5. Uncheck “Block all public access” and check “I acknowledge that the current settings might result in this bucket and the objects within becoming public.”
  6. Click “Create bucket.”

Boom, you have a bucket!

Step 2: Enable Static Website Hosting

Now, let’s enable static website hosting for your new bucket:

  1. Click on the name of your newly created bucket.
  2. Click on the “Properties” tab.
  3. Scroll down to “Static website hosting” and click “Edit.”
  4. Select “Enable” and enter “index.html” for both the Index and Error documents. This tells S3 to serve the index.html file when someone visits your site.
  5. Click “Save changes.”

Step 3: Upload Your Website Files

Next, you’ll need to upload your website files (like your index.html file) to your S3 bucket:

  1. Click on the “Objects” tab.
  2. Click “Upload.”
  3. Click “Add files,” and select the files you want to upload.
  4. Click “Upload.”

Great! Your files are now floating in a cloud (in a good way)!

Step 4: Set Bucket Permissions

We’re almost there! Now you need to ensure everyone can see your awesome website:

  1. Click on the “Permissions” tab.
  2. Scroll down to “Bucket policy” and click “Edit.”
  3. Paste in the following policy, replacing “your-bucket-name” with the name of your bucket:
  1. {
    "Principal": "*",
  2. Click “Save changes.”

Step 5: Visit Your Website

Your site is now live on the internet! You can visit it by using the endpoint URL provided in the Static website hosting card in the bucket Properties. It will look something like



What is AWS Hosting?

AWS hosting is like owning a giant robot that takes care of all your web hosting needs, so you can sip pina coladas on the beach. Amazon Web Services (AWS) offers cloud computing resources and services like EC2 instances (servers), S3 (storage), and RDS (databases) that can support your websites or web applications.

2. What is an EC2 instance?

EC2 stands for Elastic Compute Cloud, not Extra Cosmic Cookie, even though that sounds delicious. In simpler terms, an EC2 instance is a virtual server in Amazon’s cloud. You can scale these up and down (thus the ‘elastic’ part) depending on your needs.

3. What is Amazon S3?

Amazon S3 is not a sub-standard submarine or a forgettable superhero, but rather, it stands for Simple Storage Service. It’s like an infinitely expandable digital warehouse, where you can store all kinds of data – web pages, images, videos, teacup poodles (just kidding, please don’t try to upload your pets).

4. How do I connect my domain name to my EC2 instance?

Using Route 53, AWS’s DNS service. This is not to be confused with Route 66, which will not help your web traffic get where it needs to go. You’ll need to register your domain, create a Hosted Zone, add a Record Set pointing to your EC2 instance, and update your domain’s nameservers. It’s like putting up signposts on the Internet highway to guide visitors to your awesome website.

5. Is AWS free?

Well, AWS is like a buffet, there’s a little bit of everything for free, but if you want the full-course meal, you’ve got to pay. AWS offers a Free Tier which includes a t2.micro EC2 instance, 5GB of S3 storage, and more. However, usage beyond the Free Tier limits is chargeable.

6. Can I scale my resources?

Absolutely! Scaling in AWS is like going to the gym – you start with light weights (small instances) and as you get stronger (or your traffic grows), you add on more weights (larger instances or more instances). AWS’s auto-scaling allows you to do this automatically based on traffic patterns.

7. How secure is AWS?

As secure as a bear in a maximum-security wildlife reserve! AWS provides several security capabilities and services to increase privacy and control network access, including network firewalls built into Amazon VPC, and encryption in transit with TLS across all services.

8. Can I host a dynamic website on AWS?

You betcha! AWS isn’t just for static HTML pages that sit around all day doing nothing. With AWS, you can host dynamic websites, create RESTful APIs, launch a fleet of drones to deliver pizza (well, maybe not that last one).

AWS is one of the largest and most popular cloud service providers in the world, so it’s safe to assume that millions of websites, ranging from small personal blogs to large enterprise-scale web applications, are hosted on AWS.

Scroll to Top