In 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:
- Register a domain using AWS
- Create an S3 bucket that will contain your Web site
- Upload your Web site into the bucket
- 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:
- Log in to the AWS console at http://aws.amazon.com.
- At the console, click Services and then locate the Networking section, and click Route 53.
- At the Route 53 dashboard, on the left hand side, click the Registered Domains link.
- 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.
- 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.
- In the AWS console, click the Services menu again, and this time locate the Storage and Content Delivery section, and then click S3.
- In the S3 Dashboard, click the Create Bucket button.
- 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.
- 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).
- You do not need to set up logging at this time, so click Create.
- Now you have created the bucket, you will need to enable Web hosting, so click on your new bucket, and then click Properties.
- Expand the Static Website Hosting, and select the Enable website hosting radio button.
- 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.
- 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
- Using any suitable text editor such as TextEdit or Notepad, create a new file called index.html and save it somewhere on your computer.
- Within the file, add the following HTML markup:
<title>My New Site</title>
Welcome to my website
- Save the changes to the file and return to your bucket in the AWS console.
- 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.
- Now click Start Upload.
- 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.
- Click Add more permissions, and then set the Grantee to be Everyone and then select the Open/Download checkbox. Now click Save.
- 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.
- In the AWS Console, click Services, and the in the Networking section, click Route 53.
- In the Hosted Zones section, choose your domain name.
- Click the Create Record Set button, and in the Name field, type www.
- In the Type field, choose CNAME – Canonical Name.
- At the Alias, select No.
- 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.
- Leave the routing policy as Simple and click Save Record Set.
- 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.