Host Your Website With Only $0.50 A Month
Tags: aws, devops
Published: 2024-06-28 02:28:16

## How to Host Your Website for Just $0.50!

Do you want to host your website for just $0.50? You heard me right! It’s not clickbait—just keep reading.

I’m in my final year, and I have a dream of building my own portfolio website. However, there’s a significant hurdle: hosting a website is expensive. If you check out GoDaddy’s prices, you’ll be shocked

Determined to find a more affordable solution, I started researching alternatives. And guess what? I found an incredible workaround.

**Note:** The actual cost may vary slightly based on usage, but it’s still incredibly affordable compared to traditional hosting options.

### **Here’s the Plan:**

We use an AWS Free Tier account, which provides dozens of services for free. Our website content is stored in an S3 bucket, which is a storage service (also free). This way, you only pay for DNS (Route 53).

### **So Let's Get Started:**

**Steps:**

1. Create an AWS Account
2. Buy a domain from any domain site like GoDaddy
3. Upload your website content to S3
4. Point your domain name to the S3 bucket via CloudFront
5. Enjoy your website :)

### Step 1: Creating an AWS Account

Type "AWS Console" in your browser.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ebzp8z9y8nwp5lqqtq86.png)

Now create your account (you can do it! It’s easy). Remember, you have to provide your payment method before you can use AWS services, even though the services we’re using are free or very low cost.

### Step 2: Buying a Domain

Buy a domain from your favorite domain registrar. I chose GoDaddy But you can choose any registrar you like.

### Step 3: Uploading Content to AWS S3

Once you open the AWS Console, type "S3" in the search bar.

Click on **Buckets**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf2myk8z6pph8o17hv5e.png)

Give your bucket a unique name.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0dbdhum7fjkgz2tldeit.png)

To allow users to access your website, uncheck all public access restrictions.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d9xyp95asjmqv8h4t71v.png)

Inside your bucket, click on the **Upload** button to upload your website content.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i10ujtmtnrfmsa81s24s.png)

Before uploading your website files to AWS, ensure that your main file, like `index.html`, is directly visible and not inside a folder. For example, if your website files are in a folder named "my website," upload the files inside it, not the whole folder. Otherwise, AWS won’t be able to find the `index.html` to display your website.

Next, we need to enable **static web hosting** to turn your bucket into a basic web server for serving HTML, CSS, JavaScript, and images.

Go to **Properties**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yllhp3rt0fx0h4ftqlvv.png)

Click on **Edit**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/634hfn7u3k5ov2ylg0up.png)

Fill in the options as shown below:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m7g6j3uk251308pt1ibb.png)

Click on the **Bucket website endpoint** to check if your website is visible. 

If it’s not, don’t worry! Head over to the **Permissions** tab.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/me16wyk6tjg13ynktgk6.png)

Scroll down to find the **Bucket Policy**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0lrfl9drek3xrc8n552k.png)

Here’s where we’ll add a policy to make your content publicly accessible. You can use the following policy snippet:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::your-bucket-name/*"
    }
  ]
}
```

Replace `your-bucket-name` with the actual name of your S3 bucket. This policy allows anyone to read (download) objects from your bucket, which is necessary for public web access.

### Step 4: Pointing Your Domain to the S3 Bucket via Route 53

To make your domain point to your S3 bucket, use Route 53
Here’s a step-by-step guide 
**Create a Hosted Zone in Route 53**: For your domain to manage DNS settings.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7awra204les5tsjqoav1.png)

**Add DNS Records:** Set up the necessary DNS records (usually A or CNAME records) in Route 53 that point to your S3 bucket. **Remember Route charge 0.50$ for each A record** ( so be careful).

**Update Name Servers**: If your domain is registered with another provider, update the name servers to those provided by Route 53.


----------------------------------------------------------

### Step 5: Enjoy Your Website!

You’re all set! Your website should now be live and accessible via your custom domain. Hosting for just $0.50? Mission accomplished!

---

If you are facing any issues, just write in the comments, and I will help you.