- The free usage tier does have some requirements that you must meet. If you do not meet those requirements or you use more than allowed you will be charged.
- EC2 by default uses dynamic IP addresses. This means that each time you restart your instance the IP address changes. Static IP addresses are available but they do cost a small amount of money.
- EC2 disk storage by default is volatile. This means that when the instance is shut down either accidentally, by Amazon, or purposefully, any data being stored on it will disappear forever. There are backup mechanisms and ways of creating persistant storage but they cost money and require more advanced administration than will be covered in this article.
- A micro instance is Amazon’s smallest instance in terms of CPU, memory, and disk space. It is more than adequate for testing, most personal websites, and probably most small business websites. If it ends up not being enough to fulfill your particular requirements a larger instance that costs money would be needed.
- We are not responsible for any fees you may incur or havoc you may cause.
- Go to http://aws.amazon.com/ and click the button on the right side of the screen that says “Sign Up Now”.
- If you already have an Amazon account you can login using your current credentials. If not, choose “I am a new user” and click the sign in button to create a new account. You will go through a typical account creation process that should be pretty self explanatory.
- They will ask you for billing information. You will have to enter this information in order to create your free web hosting virtual server. The reason for this is in case you happen to use more than what is allowed for the free tier or use any additional services that do happen to have a fee associated with them.
- After you go through a verification process, I recommend the phone verification method, it will generally take a couple of minutes before you receive an account activation email. Once you receive the email you can go to http://aws.amazon.com/account/ and begin managing your account. Now the real fun begins.
Step Two: Navigate Your Way To The Management Console
- First, make sure you are at http://aws.amazon.com/account/.
- Click on the “Manage Your Account” link. It’s the bottom option on the left. You will probably be asked to login which you can now do using your current Amazon account or the one you just created. From this point forward if you are asked to login again, do it.
- You should now be at the “Manage Your Account” screen and there should be quite a few options shown under “Services You’re Signed Up For”. Ignore all of that and go to the “My Account / Console” drop down on the top right side of the screen and select “AWS Management Console”. Alternatively you can just click here, which we could have done at the beginning of this section but I wanted you to see the “normal” way of getting there. Once all is said and done you should see something resembling this:
Step Three: Firing Up Your Instance
- In the EC2 world your servers are called “instances.” You should currently be at the “AWS Management Console“. On the top there are multiple tabs. The one we are interested in is labeled EC2. Click it.
- Since this is a new account you should see a little message telling you that you have no running instances followed by a button that says “Launch Instance”. Click that button.
- From the “Request Instance Wizard” choose either “Basic 32-bit Amazon Linux AMI…” or “”Basic 64-bit Amazon Linux AMI…”
- Make sure you have 1 in the “Number of Instances” box and that “Micro…” is selected from the “Instance Type” drop down. You can choose a particular “Availability Zone” if you want but for now it’s easier to just leave it set as “No Preference”. Click the “Continue” button.
- Leave everything set to the defaults and click the “Continue” button again.
- To the right of “Name” enter a name for your instance. You can leave this blank but if you ever decide to startup more instances this is a handy way to keep track of them.
- Now things get tricky, you need to create a key pair in order to securely log into your server. You can also use this key pair for other future servers that you may launch in the future. Enter a meaningful name and click “Create & Download your key pair”. Save it to a place where you will not forget it and make sure you keep it secure. If someone has this key they can log into your instance and do bad things. I’ll leave the actual act of securing the key as an exercise for the reader. For now, lets keep moving and click the “Continue” button.
- A security group is a set of firewall rules for your instance. In our case we want port 22 for SSH and port 80 for HTTP opened up. Port 22 should already be in the set of existing rules that are shown in the blue box:
To add HTTP select “HTTP” from the “Create a new rule” drop down box and then click the “Add Rule” button. Now we can login via SSH and view web pages over port 80. Click the “Continue” button.
- You should now see a confirmation window that shows all of the settings for your shiny new instance. Click the “Launch” button and then click the “Close” button when the next window shows up.
- After being in the “pending” state with a yellow light for a few seconds your instance will eventually show up as being in the “running” state with a green light:
Green light means go, so lets go!
Step Four: Logging Into Your Instance
- Now you have a running EC2 micro instance that should qualify for the free tier of services. Remember though, if you use above and beyond the free usage tier, you will be charged for those services and amounts that do go above. It isn’t much though, so even if you do get charged it’s not too bad.
- Click on your instance in the management console and the bottom of your browser should show some important information about your instance. Find the value labeled “Public DNS”. This is the external hostname of your instance and you will need this to login.
- As stated in the warnings, your instance has a dynamic IP address by default. You can add an “Elastic IP” to make it static but it does cost a small amount of money. There is an “Elastic IP’s” menu option under “Navigation” should you want to play around with this feature.
- Remember that key you downloaded? You’re going to need it now. Depending on whether or not you are on Mac, Windows, or Linux the application you use to login will be different. For Mac and Linux you will probably use SSH and it is probably already installed. If you are on Windows I recommend using PuTTY. For PuTTY on Windows checkout this tutorial on how to setup PuTTY using the EC2 key you downloaded. For SSH simply issue the following command using the path to your key and the IP address or external hostname of your instance: ssh -i PATH-TO-KEY ec2-user@IP-OR-HOSTNAME
- Beyond what I just wrote I’m going to leave figuring out how to login to your EC2 instance up to the reader. There is a lot of information on the Internet about how to do just that. When you do successfully login you should see something like this:
Step Five: Setting Up Your Instance
- I’m assuming that at this point you have successfully logged into your instance. Now we are going to install some basic software for hosting a basic website using the LAMP (Linux/Apache/MySQL/PHP) stack.
- From the command line issue the following command: sudo yum -y update; sudo yum -y install httpd php mysql mysql-server This will update the software on your instance and install the basic LAMP stack.
- From the command line issue the following command: sudo /etc/init.d/httpd start; sudo /etc/init.d/mysqld start This will start up the MySQL database and the Apache web server.
- From the command line issue the following command: sudo chkconfig httpd on; sudo chkconfig mysqld on This will make it so that your web server and database will restart after a reboot.
You can install WordPress, Drupal, or almost any other PHP based application.
- Log into your Name.com account and navigate to the DNS management section for the domain you would like to point to your instance.
- The easiest thing to do is simply create a CNAME record for *.YOURDOMAIN.TLD and just YOURDOMAIN.TLD. Under the “Record Answer” section put the external hostname of your instance for both CNAME records.
- Alternatively you can ping the external hostname, get it’s IP address, and create A records using the IP address as your “Record Answer”. You would want to do this if you have other records on that domain such as MX records for email.
- Properly setup DNS using CNAMEs will look like this under DNS management:
- Once your DNS is setup and propagated (usually within 5 – 10 minutes) you will be able to get to your webpage and instance via your domain.
- Want to make it so that you never have to go through all of that again when creating a web hosting instance? Right click on your instance in the AWS Management console and select the “Create Image…” option. This will put it under your “IMAGES” -> “AMI’s” section of the “Navigation” menu. In the future you can simply right click on the image and select “Launch Instance”. If the content of your site rarely changes this could work well for your backup solution. The image will use storage space at Amazon and may incur some nominal fees.
- As we already mentioned the storage on a default instance is volatile. You can use the “Elastic Block Storage” service to create persistant storage. I won’t go into details here but searching for “how to create and mount elastic block storage” on Google will yield all sorts of how to results. You will need to remap your Apache and MySQL configurations as well in order to make that data persistent but for a real world server you will probably want to do just that. The additional storage does have a price but it is more than reasonable.
- If you need to know more remember that Google is your friend.
If we get some requests from you all and these sorts of posts seem popular we may do future articles on how to install various applications and do more using your instance. Should Name.com offer easy one click EC2 instance setup for various web services? Let us know!