Host Your Website on a new domain in 20 minutes on AWS

applenotebookIn this blog post you will see how to host your own web site on your own domain at trivial cost.

Specifically, you will learn how to:

  1. Register a domain using AWS
  2. Create an S3 bucket that will contain your Web site
  3. Upload your Web site into the bucket
  4. Configure the DNS settings using Route 53 so your domain points to your Web pages

So lets get started with registering a domain.

Registering your Domain using AWS

To register your domain, you will firstly need to create an AWS account if you do not already have one. This can be done by visiting http://aws.amazon.com.

Once you have an account, complete the following steps:

  1. Log in to the AWS console at http://aws.amazon.com.
  2. At the console, click Services and then locate the Networking section, and click Route 53.
  3. At the Route 53 dashboard, on the left hand side, click the Registered Domains link.
  4. In the Register domain section, you can now search for a domain that you would like to use. You can use the Check button to ensure that the domain you want is not already taken.
  5. Once you have found something you want, click Add to Cart and complete the purchase.

Now that was easy! You are the proud owner of your new domain name. We now need to get a basic Web page created and placed onto the end of the URL.

Create the S3 Bucket to Host your Web Site

Now you have the domain registered, you can create an S3 bucket to store the Web site in. S3 stands for Simple Storage Service and it allows you to store files, web pages and such like in the cloud. It is very cost effective, especially for a static Web site. S3 stores objects (files) in things called buckets. You can create buckets in your AWS account and put files there. You can then optionally make these files available as a Web site, which is what you will do today.

  1. In the AWS console, click the Services menu again, and this time locate the Storage and Content Delivery section, and then click S3.
  2. In the S3 Dashboard, click the Create Bucket button.
  3. At the Create a Bucket dialog, enter the name for the bucket. The name must be the same as your Web site domain name, so ensure that it matches. We will use www.yourdomain.com. For example, if your domain is conygre.com, then your bucket name needs to be www.conygre.com. It is important for buckets used for Web hosting that the name of the bucket is the same as the name of the domain it is hosted on.
  4. Choose the most appropriate region. Unless you are doing something with special sensitivities, I would use the one nearest to your users as this will result in the lowest latency (fastest response times).
  5. You do not need to set up logging at this time, so click Create.
  6. Now you have created the bucket, you will need to enable Web hosting, so click on your new bucket, and then click Properties.
  7. Expand the Static Website Hosting, and select the Enable website hosting radio button.
  8. Enter index.html for the name of the Index document, and error.html for the name of the error page to be used if there is a problem. You will upload these pages later.
  9. Click Save to save your changes.

You will now upload a basic web page to test your bucket out.

Create and Upload a Basic Web Page

  1. Using any suitable text editor such as TextEdit or Notepad, create a new file called index.html and save it somewhere on your computer.
  2. Within the file, add the following HTML markup:

<html>
  <head>
    <title>My New Site</title>
  </head>
  <body>
    Welcome to my website
  </body>
</html>

  1. Save the changes to the file and return to your bucket in the AWS console.
  2. Click the Upload button and then using Finder or Windows Explorer, locate your new file, and drag it into the ‘Drag and drop files and folders to upload here.‘ part of the AWS dashboard.
  3. Now click Start Upload.
  4. Your file will upload very quickly, but will not be available online yet since the default permission on files in buckets is that the public cannot see the files. You will change that now. In the left pane, select your new file, and then in the right pane, expand Permissions.
  5. Click Add more permissions, and then set the Grantee to be Everyone and then select the Open/Download checkbox. Now click Save.
  6. To verify that your file is working, you can view it using the bucket’s AWS domain name.  At the top of the right pane is the Link to the object. If you click it, you will see your Web page in the browser, but the link is not too nice! Finally, you will set your own domain name to point to this page.

Using your domain for the Bucket

You are now nearly finished. The last thing to do is to point your new domain at the bucket so you don’t need to use that very long AWS URL to see the page.

  1. In the AWS Console, click Services, and the in the Networking section, click Route 53.
  2. In the Hosted Zones section, choose your domain name.
  3. Click the Create Record Set button, and in the Name field, type www.
  4. In the Type field, choose CNAME – Canonical Name.
  5. At the Alias, select No.
  6. In the Value field, begin typing www. and it should prompt you for the rest of your bucket name. If not, enter the rest of your bucket name URL. It must be the same as the link you visited in the browser earlier on when you tested your page. Just remove the http:// from the front of it. If you are having trouble at this point. Check that you definitely made your bucket a Web site by reviewing that you successfully completed the earlier steps. This Value field in Route 53 will not auto-populate if you have done something incorrectly earlier on in the process.
  7. Leave the routing policy as Simple and click Save Record Set.
  8. That’s it! Now visit your domain www.yourdomain.com in a browser and it will show your page. It sometimes takes a few minutes to propagate your new domain name around the Internet, so don’t worry if it doesn’t work instantly. If it doesn’t work after around 5 minutes, you have probably done something wrong.

So what you have seen in  this brief tutorial is how to get a Web site up and running on AWS using your own brand new Domain name.

Add a Comment

Your email address will not be published. Required fields are marked *