Static Website hosting on Amazon S3
You can host a static website on Amazon S3.Now many organization running their websites in S3 with their custom domain name effectively .On a static website, individual web pages include static content and they might also contain client-side scripts.
You can not run dynamic websites on S3 .The reason is dynamic website relies on server-side processing, including server-side scripts such as PHP, JSP, or ASP.NET. Amazon S3 does not support server-side scripting.
You can simply upload some data and make them publicly accessible , but “S3 website endpoint” will be created for the bucket. Which you can map with your custom domain name.
Now lets see how to configure website “static.findoutthat.com“ in S3
1.Create a bucket called “static.findoutthat.com” in s3 your preferred region .
Create bucket with same your domain name.
2.Upload your websites static content files into S3 bucket . here S3 bucket “static.findoutthat.com”
The content can be text files, family photos, videos—whatever you want. If you have not yet created a website, then you only need one file for this example. You can upload any file. For example, you can create a file using the following HTML and upload it to the bucket. The file name of the home page of a website is typically index.html, but you can give it any name. In a later step, you provide this file name as the index document name for your website.
Create the file with notepad name “index.html” and save
Source Code ;
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Findouthat Website Home Page</title> </head> <body> <h1>Welcome to Findouthat website</h1> <p>Now hosted on Amazon S3!</p> </body> </html>
3.Configure permissions for your objects to make them publicly accessible
Either you can make selecting all object and make it public or You can create bucket policy . But bucket policy is better one . Even in future if you add any object the permission will assign automatically . You no need to allow again.
Create a bucket policy and attach with the specific bucket.
Source code: You can replace the bucket with your own bucket name
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::static.findoutthat.com/*" } ] }
4.Enable Static website hosting for bucket
Select the bucket and enable website hostling
5.Testing Your Website
You can note down the S3 bucket endpoint name from above steps .
Endpoint: http://static.findoutthat.com.s3-website-us-west-2.amazonaws.com
Website is running fine . Now you can map with your custom domain.
6.Point your website to S3 bucket.
You can use your existing DNS Service provider like Godaddy or Amazou Route 53 if you have already moved to AWS.
Now lets see in godaddy how to make DNS entry . You have to create with “CNAME” records
In DNS Manage page
You can refer AWS documents to add entry in Amazon route 53.
7.Final test
After 5 min you access your websites with your custom domain name rather than s3 website endpoint name
Thats All! Good Luck to run your website.