DEV Community

NITESH TALIYAN
NITESH TALIYAN

Posted on

Host a static website on AWS

Image description
To host a static website on Amazon S3 and use a custom domain with Amazon Route 53, you can follow these steps:
Sign up for an AWS account if you don't already have one:

Go to the AWS homepage and click the "Create a new AWS account" button.
Follow the on-screen instructions to create your account.

  1. Create a new S3 bucket:
    Sign in to the AWS Management Console and open the Amazon S3 console.
    Click the "Create bucket" button.
    Give your bucket a unique name, select a region, and click "Create."

  2. Upload your website's files to the bucket:
    Select the bucket you just created, and click the "Upload" button.
    Drag and drop your website's files into the upload window, or use the "Add files" button to select them manually.
    Click "Next" to continue.
    On the next screen, you can set permissions and other options for your uploaded files. When you're ready, click "Next" again.
    Review your settings and click "Upload" to start the upload process.

  3. Make the bucket accessible as a website:
    In the Amazon S3 console, select the bucket you just created.
    Click the "Properties" button, and then click the "Static website hosting" option.
    Select the "Use this bucket to host a website" option and enter the "Index document" and "Error document" for your website. The index document is usually called "index.html" or "index.php."
    Click "Save" to apply the changes.

  4. Set up a custom domain with Amazon Route 53:
    In the AWS Management Console, navigate to the Amazon Route 53 console.
    Click the "Create Hosted Zone" button.
    Enter your domain name and click "Create."
    Route 53 will create a hosted zone for your domain and display a list of name servers.
    Go to your domain registrar's website and update the name servers for your domain to the ones provided by Route 53. This will allow Route 53 to manage the DNS for your domain.
    In the Route 53 console, click the "Create Record Set" button.
    In the "Name" field, enter the subdomain you want to use for your website (e.g., www).
    For the "Type," select "Aβ€Š-β€ŠIPv4 address."
    For the "Value," enter the endpoint URL for your S3 website, which you can find in the S3 console under "Properties" > "Static website hosting."
    Click "Create" to create the record set.

  5. Test your website:
    In the Amazon S3 console, click the "Properties" button and then click the "Static website hosting" option.
    Copy the "Endpoint" URL shown in the Static website hosting panel and paste it into a web browser. Your website should now be accessible at this URL.
    If you set up a custom domain, you can use that instead of the endpoint URL to access your website.

That's it! Your static website should now be live and accessible at your custom domain. If you run into any issues or have any questions, feel free to ask.

Top comments (0)