alex_bn_lee

导航

[1048] Hosting a static website using Amazon S3

ref: Hosting a static website using Amazon S3

ref: Tutorial: Configuring a static website on Amazon S3


To host a static website on an Amazon S3 bucket, follow these steps:

Step-by-Step Guide

  1. Create an S3 Bucket:

    • Open the Amazon S3 console.
    • Click on “Create bucket”.
    • Enter a unique bucket name and choose a region.
    • Click “Create bucket”.
  2. Upload Your Website Files:

    • Select your newly created bucket.
    • Click on “Upload” and add your website files (e.g., index.html, error.html).
  3. Enable Static Website Hosting:

    • Go to the “Properties” tab of your bucket.
    • Scroll down to “Static website hosting” and click “Edit”.
    • Select “Use this bucket to host a website”.
    • Specify the index document (e.g., index.html) and error document (e.g., error.html).
    • Click “Save changes”.
  4. Set Bucket Policy for Public Access:

    • Go to the “Permissions” tab.
    • Scroll down to “Bucket policy” and click “Edit”.
    • Add a policy to allow public read access:
      {
        "Version": "2012-10-17",
        "Statement": [
          {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::your-bucket-name/*"
          }
        ]
      }
    • Replace your-bucket-name with the name of your bucket.
    • Click “Save changes”.
  5. Disable Block Public Access:

    • In the “Permissions” tab, click “Edit” under “Block public access (bucket settings)”.
    • Uncheck “Block all public access” and confirm the changes.
  6. Access Your Website:

    • Your website will be available at the endpoint URL provided in the “Static website hosting” section. It will look something like http://your-bucket-name.s3-website-region.amazonaws.com.

Example

If your bucket is named example-bucket and is in the us-east-1 region, your website URL will be:

http://example-bucket.s3-website-us-east-1.amazonaws.com

For more detailed instructions, you can refer to the AWS documentation12.

Would you like help with anything else?

 

posted on 2024-08-27 13:36  McDelfino  阅读(4)  评论(0编辑  收藏  举报