Purpose

Start up a server using Amazon Web Services using the Free tier.

What will you need?

  • A computer with the operating system you would like to use. (In this case i will use Ubuntu Server)
  • You will need to create an Amazon web services account (if you haven't already)
  • An Amazon Web Service Instance (EC2)

Preface

At the end of this tutorial you should have a running Amazon instance at no cost (for one year) and hopefully answer any questions you may have regarding the set up.

Tutorial

Step 1. Logging into Amazon Web Services and setting up the Instance

-After signing up for Amazon Web Services, Open a web browser and go to (http://aws.amazon.com/console/)

-You will then get a screen similar to this (at the time of writing this)

Launch Instance

  • Click sign into the AWS console and you will get the following screen to enter your log in information.

Launch Instance

-Once you are succesfully logged in, you will get the following screen:

Launch Instance

-Now click on EC2 under "Compute" and your screen will now look like this:

Launch Instance

-Next click on Launch Instance and your screen will now look like this:

Launch Instance

-Select the Amazon Machine Image you would like (in this case im going to select Ubuntu Server 14.04 LTS)

-Click select next to the image you would like and your screen will now change to the following:

Launch Instance

-leave everything as default and click "Review and Launch" on the bottom of the screen. Your next screen will look like the following

Launch Instance

-Now click Launch (on the bottom right corner) and your screen will now ask to create or select a pair key like the following:

Launch Instance

-Make sure "Create a new pair key" is selected and enter a name for the key (it doesn't matter what you name it)

-Now click "Download Key Pair" and make sure you know where it is downloaded to (we will need this later to ssh)

-Now click "Launch Instance" in the bottom right corner and you will get the following screen:

Launch Instance

-Scroll down and on the bottom right corner you will see "View Instances". Click that and you will now see the following:

Launch Instance

-You will only see one instance running (unlike mine where i had one previously)

-Make sure under "Instance Status" it says "running"

-Now you are ready to connect to your instance!

-Leave your browser open and fire up your command line (i will be using Ubuntu for the following commands)

Step 2. Connecting to your Instance using SSH

-Open a terminal on your machine

-navigate to the directory your key was downloaded to (for example mine is in my Downloads directory)

-Remember use the command "cd" followed by the directory you would like to navigate to

-the following terminal screenshot shows me navigating to my Downloads folder using the "cd" command

Launch Instance

-As you can see i navigated to my Downloads folder (remember it is case sensetive)

-I then typed "ls" which displays the files in the current directory i am in (in this case i only have 2 files)

-Your key will be named whatever you called it followed by the .pem extension.

-For example, i called my key file "KeyforInstance" so my file is called KeyforInstance.pem

-once you have successfully located and navigated to the directory your key is in, stay in that directory and you will need the following information:

-Your key file name, your Amazon Instance IP address and the username (in this case it is Ubuntu)

-to find your ip address go back to your browser and look at your instance again, and at the bottom under descripton it will be labeled as "Public IP" (Refresh your page if you do not see it)

Launch Instance

-Once you have all that information, this will be the format for your instance:

-"ssh -i "keyfilename" username@ipaddress"

-the following command capture will show me entering this command with my instance information:

Launch Instance

-Notice i am still in the directory my key file is in.

-Also notice i got permission denied because my key file is not protected we will fix that in the following command

-to change our key file permission so we do not get permission denied, make sure you are in the key files directory and enter:

-"chmod 400 keyfilename"

-the following screenshot will show an example of me doing this to my key file.

Launch Instance

-As you can see i entered "chmod 400 KeyforInstance.pem" because my key file name is KeyforInstance.pem.

-After you enter it you will not get any feedback from the command line.

-To check to make sure the key file's permissions changed successfully type "ls -la" and should show my file permissions as -r---------

-once you see that file permissions have changed enter the same command again "ssh -i "yourkeyfilename" username@ipaddress"

-If you changed your file permissions correctly and typed the correct information you will get the following screen:

Launch Instance

-You have now successfully logged into your Instance!

Step 3. Once you're logged into your Instance

-Once you are logged into your instance here are a few commands you should enter before doing whatever it is you're going to do.

-if you type the command "sudo su" this will log you in as root on your current instance

-the following screenshot shows the result of entering this command:

Launch Instance

-Another command you might want to enter is "apt-get update" (which will update your packages)

-Also "apt-get upgrade" is another useful command.

-Also if you would like to install LAMP (Linux-Apache-MySQL-PHP) server on your Instance, type the command "tasksel"

-The following screenshot shows the result of entering this command:

Launch Instance

-Once you are on this screen use the arrows on your keyboard to navigate up and down

-To select a software to install, navigate to it and hit the spacebar, that will then put a star in the box next to it

-once you have selected everything you want to install hit the tab key and then press enter.

-You will then get a screen that looks like this:

Launch Instance

-If you read the prompt it says that a new password is not manditory (so if you would like to create a new password for the mySQL root user feel free to, although it is not required)

-If you choose to not enter a password, hit the down arrow key and hit enter (note as the installation goes, it will ask you multiple times again to enter a password if you choose not to, just keep hitting "OK" to not enter one)

-Once it is done installing, it will take you back to the command line.

-After that you are free to do what you like!

A Few More Things

-A few things to note:

-If you would like to shutdown your instance (which i suggest you do if you're not using it) do the following:

-go to your Instances on Amazon Web Services, click on your instance, click "Actions", hover over "instance state", and click "Stop"

-The following screenshot shows me doing this to my instance:

Launch Instance

-note that if you select "stop" it will stop the instance yes, but amazon wil charge you per month for it

-if you click "terminate", they will not, but realize it will completely ERASE your instance, meaning you will have to go through the setup of an instance again.

-Also note everytime your Instance is stopped and turned back on, it will have a new IP address

-If you would like to have a static ip address, read this link for information Elastic IP

-Good luck and have fun!