AWS Series II using EC2

Source: Internet
Author: User

In this article, we have three tasks. 1. Use the Amazon Management Console to create an EC2 instance. Second, use the local command line tool to remotely log on to the EC2 instance. Third: create a web service on the EC2 instance and access the Web service through a public domain name.

If you do not have an AWS account, you can use the free lab provided by qwiklabs for this exercise. The address is https://run.qwiklabs.com.

Log on to the Amazon AWS Service Management Console and select the EC2 service.

Then you can go to the EC2 control panel.

Click the above buttonLaunch InstanceTo create a new EC2 instance.

First, you must select the machine's image file AMI (Amazon machine image). There are various Linux distributions and Windows systems. In this experiment, we select the first one, Amazon Linux AMI, and Amazon's own Linux release.

Then select the machine type. The performance of different types of machines varies with the charging standard. Everything is determined based on your needs. Select the first one, which is the cheapest.

Then you have two options: ClickReview and LaunchStart the new machine directly, use the default values for other parameters, and clickNext:Configure Instance DetailsCustomize other configurations. Here we select the second button until Step 6: Configure Security Group.

You can use an existing security group or create a new one. In a security group, you can set a series of policies to manage access between the instance and the outside world.

Because we need to remotely log on to this instance and the instance needs to provide HTTP services, we need to open ports 22 and 80. Port 22 is open by default, and port 80 needs to be opened manually. ClickAdd RoleButton and add a new role.

ClickLaunchButton, a page will pop up asking you to set key pair.

This key pair is used to establish a secure connection with the instance. Amazon stores a public key and stores a private key locally. to connect to the instance, you must provide a private key. Here we choose to create a new key pair, named awsworkshop, and save it to the local device. It will be used to SSH to the instance later.

ClickLaunch InstancesThe instance is initialized.

ClickView InstancesTo view the newly created instance.

It usually takes 3 to 5 minutes to initialize the new instance. You can view information about the instance. Amazon assigns a public IP address and a public DNS domain name to the instance. You need to use them later.

Wait untilInstance StatusIsrunningThen, we can perform the second task, that is, remotely connect to the instance.

Open your favorite terminal, and then upgrade the permissions of the saved PEM file.

1
$: chmod 600 ~/Downloads/awsworkshop.pem

Then find the public IP of the instance on the AWS control panel and SSH to the instance using the ec2-user username.

1
$: ssh [email protected] -i ~/Downloads/awsworkshop.pem

You can connect to the remote instance after waiting.

12
[[email protected] ~]$ whoec2-user pts/0        2014-07-26 06:38 (123-243-183-184.static.tpgi.com.au)

How is it? Everything is simple, right?

Next we will conduct the last task of this experiment and build a web server on this remote instance.

After SSH to the instance, run the following command.

1
$: sudo yum install httpd

This command is used to install the httpd server of Apache.

Then jump/var/www/htmlDirectory, and create a newindex.html.

12
$: cd /var/www/html$: sudo touch index.html

Use the editor you used to input an HTML document in the file and save it.

12345

Start the web server.

1
$: sudo service httpd start

As a result, find the public DNS from the control panel of the EC2 instance and paste it into the browser to access the Web service provided by the instance.

All three tasks are completed. I hope you will enjoy this EC2 tour.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.