Wednesday, May 25, 2011

Hosting a simple website on Amazon S3

I assume you have already signed up for Amazon Web Services S3.  I also assume you have a domain registrar. For this example I'll be using GoDaddy, but there are other popular registrars.
  1. Register your domain
    1. Do this first if you haven't already to make sure you get the domain name you want.
    2. For these instructions I'll use example.com as the example domain.
  2. Create Bucket named for your domain
    1. Sign into AWS Management Console for S3
    2. Under Buckets, click Create Bucket
    3. Name the bucket: www.example.comThis should be the full host plus domain name
    4. Click Create
  3. Upload files (e.g. index.html)
    1. Select www.example.com from the list of buckets on the left
    2. Click Upload
    3. If prompted by your browser, enable Java for the uploader to work.  
    4. Click Enable Enhanced Uploader
      (I could not get the Add Files button to work in Chrome w/out the enhanced uploader)
    5. Click Add Items
    6. Browse and select files to upload for your website.  I will assume you at least have an index.html file.
      You can use Ctrl+Click to select multiple files.  Then click Open.
    7. Click Start Upload
  4. Make bucket a website
    1. Right click on www.example.com in the Buckets list
    2. Select Properties
    3. In the lower pane, select the Website tab
    4. Check Enabled
    5. Enter index.html for Index Document.
    6. Click Save
    7. Click the Endpoint link to verify it is online.
    8. Copy the endpoint link to your clipboard.  Typically something like: http://www.example.com.s3-website-us-east-1.amazonaws.com/
  5. Create a CName record for www.example.com
    1. Log into My Account on GoDaddy
    2. Go to the DNS Manager
    3. Click Edit Zones beneath example.com
    4. In the CNAME (Alias) table:
    5. Click the www row (usually the last row)
    6. In the second column (Points to) paste the endpoint link, removing the http:// and the trailing slash: www.example.com.s3-website-us-east-1.amazonaws.com
    7. Click outside the row to finish editing
    8. Click Save Zone File
    9. Click OK if prompted
    10. Periodically try opening www.example.com in a new web browser, or just wait for an email from GoDaddy letting you know your changes were effected.
    11. You may have to wait for these changes to take effect to move onto the next step.  
  6. Redirect root (example.com)
    1. Go to the Domain Manager
    2. Check the box by EXAMPLE.COM
    3. Click Forward, Forward Domain in the toolbar above the list
    4. Enter www.example.com in the box after http://
    5. Click OK
    6. Periodically try opening example.com in a new web browser, or just wait for an email from GoDaddy letting you know your changes were effected.
  7. Newly uploaded files need to be made public
    1. After you update or upload new files to S3:
    2. Right click on the file and select Make Public
    3. You can use Ctrl or Shift for multiple select

No comments:

Post a Comment