Difference between revisions of "Amazon Web Services"

From CSE330 Wiki
Jump to navigationJump to search
Line 16: Line 16:
  
 
# Use the Classic Wizard.
 
# Use the Classic Wizard.
# Now choose what distribution of Linux you would like to use.  For more information on distributions, refer to [[Linux#Linux Distributions|the Linux guide]].  The following are both good choices, and throughout the wiki, the instructions are equally comprehensive for both.  This semester, we will be teaching this class using Ubuntu, but you are free to use either one.
+
# Now choose what distribution of Linux you would like to use.  For more information on distributions, refer to [[Linux#Linux Distributions|the Linux guide]].  The following are both good choices, and throughout the wiki, the instructions are equally comprehensive for both and you are free to use either one.
#* Ubuntu Server 14.04 LTS (based on Debian)
 
 
#* Amazon Linux AMI (based on RHEL)
 
#* Amazon Linux AMI (based on RHEL)
 +
#* Ubuntu Server 14.04 LTS (based on Debian)  - DO NOT SELECT Ubuntu Server 16.04
 
# The default instance variables are all fine.  Click Continue until you get to the "Create Key Pair" screen.
 
# The default instance variables are all fine.  Click Continue until you get to the "Create Key Pair" screen.
 
# Create a new Key Pair.  Enter some name for it, and then click "Create & Download your Key Pair".  '''Save your key somewhere secure.'''  In addition to using it to authenticate for this instance, you will be able to use the same key for additional instances.
 
# Create a new Key Pair.  Enter some name for it, and then click "Create & Download your Key Pair".  '''Save your key somewhere secure.'''  In addition to using it to authenticate for this instance, you will be able to use the same key for additional instances.

Revision as of 15:08, 13 January 2017

Amazon Web Services provides a method to publish web sites on virtual machines in the "cloud." In CSE330, you will be using an EC2 instance to host your web site.

Before reading this guide, you should be familiar with Linux and the various distributions of Linux. Fore more information, refer to the Linux guide.

Creating and Configuring your EC2 Instance

Follow these steps to get to the AWS Management Console:

  1. Create an AWS account: http://aws.amazon.com/
  2. Sign up for the EC2 Web Service: http://aws.amazon.com/ec2/
  3. Log in to the AWS Management Console

To create your new virtual machine, click Launch Instance. Do the following to configure your instance:

  1. Use the Classic Wizard.
  2. Now choose what distribution of Linux you would like to use. For more information on distributions, refer to the Linux guide. The following are both good choices, and throughout the wiki, the instructions are equally comprehensive for both and you are free to use either one.
    • Amazon Linux AMI (based on RHEL)
    • Ubuntu Server 14.04 LTS (based on Debian) - DO NOT SELECT Ubuntu Server 16.04
  3. The default instance variables are all fine. Click Continue until you get to the "Create Key Pair" screen.
  4. Create a new Key Pair. Enter some name for it, and then click "Create & Download your Key Pair". Save your key somewhere secure. In addition to using it to authenticate for this instance, you will be able to use the same key for additional instances.
  5. Create a new Security Group and connect it to your server. The security groups you create determine whether a port is open or blocked for your server.
    • You need to open the SSH port on your server. To do this, select "SSH" from the drop-down box, and then click "Add Rule."
    We will be opening more ports by modifying the security group at a later time. Click Continue.
  6. You are now ready to launch your virtual server! Click Launch.

Starting and Stopping your EC2 Instance

You can start and stop your instance by right-clicking on the instance. The options are down in the "Instance Lifecycle" section.

Amazon EC2 Gives You One Free Micro Instance

It is free to keep one micro instance running at all times. Keeping your instance running around the clock will make your life easier, because then you won't need to always change your hostname in your SSH clients.

For additional Micro instances, or for larger instances, you will be charged hourly for their use. One non-free Micro instance costs about $14/month; a Small instance costs about $43/month.

Terminate vs Stop

Never "terminate" your instance, as this PERMANENTLY DELETES the instance! Any time you are done using the instance you should instead "stop" the instance and then when you are ready to resume work you should "start" the instance.

Note: Frequently committing your work to your repository is a safety net in case something horrible happens to your instance.

Enabling Web Access to your EC2 Instance

Once you have configured Apache (which you will do later in this Module), you will need to open up your EC2 instance to web traffic. (By default amazon blocks all traffic to our instance.)

Go to the Security Groups under Network & Security on the EC2 webpage. Select your security group, click on the Inbound Tab. Add a new Custom TCP rule with a Port range of 80. Leave the Source at 0.0.0.0/0 (for all traffic). Click Add Rule, and then click Apply Rule Change.

To make sure things are working, create a file, like hello.txt, in your web server root. Give it some content (might I suggest "Hello, world!").

  • In the Amazon AMI, the web server root is at /var/www/html
  • In Ubuntu 12.04 LTS, the web server root is at /var/www
  • In Ubuntu 14.04 LTS, the web server root is at /var/www/html

For more information on editing files on the command line, refer to the Linux guide.

You should now be able to visit your server load up the file using your web browser! Example Link: http://ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com/hello.txt

NOTE:depending on the city in which your server is located, your link might look like:

http://ec2-xxx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/hello.txt