Today I am going to create my Amazon EC2 instance (Amazon Linux), install Apache web server in the instance and create my public web pate.
You can create your own as well. just follow the steps below.
Refer to A Cloud Guru A Certified Developer - Associate lectures for more details.
[AWS Certificate] 로 시작하는 글들은 제가 AWS Certified Developer - Associate 을 준비하면서 배운 내용들을 메모해 두는 글입니다.
이번 글은 EC2 instance 와 어디서나 접근할 수 있는 나의 웹 페이지를 만드는 방법을 정리했습니다.
따라하시면 무료로 리눅스 서버와 개인 홈페이지 공간을 얻을 수 있습니다.
- Navigate to EC2 page. https://console.aws.amazon.com/ec2 And Click on Launch Instance button
- Select AMI (Amazon Machine Image) as Amazon Linux
Amazon Machine Image
An Amazon Machine Image (AMI) is a special type of virtual appliance that is used to create a virtual machine within the Amazon Elastic Compute Cloud ("EC2"). It serves as the basic unit of deployment for services delivered using EC2.
Amazon Machine Images (AMI)
An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the cloud. You specify an AMI when you launch an instance, and you can launch as many instances from the AMI as you need. You can also launch instances from as many different AMIs as you need.
An AMI includes the following:
A template for the root volume for the instance (for example, an operating system, an application server, and applications)
Launch permissions that control which AWS accounts can use the AMI to launch instances
A block device mapping that specifies the volumes to attach to the instance when it's launched
- Select the default t2.micro and Click on Next:Configure Instance Details button
Amazon EC2 provides a wide selection of instance types optimized to fit different use cases. Instance types comprise varying combinations of CPU, memory, storage, and networking capacity and give you the flexibility to choose the appropriate mix of resources for your applications. Each instance type includes one or more instance sizes, allowing you to scale your resources to the requirements of your target workload.
- Set Defaults and Click on Next: Add Storage button
Subnet : 1 Subnet is always equal to 1 Availability (******) Exam
Amazon EC2 Spot instances allow you to bid on spare Amazon EC2 computing capacity. Since Spot instances are often available at a discount compared to On-Demand pricing, you can significantly reduce the cost of running your applications, grow your application’s compute capacity and throughput for the same budget, and enable new types of cloud computing applications.
* There is no Spot capacity for instance type t2.micro in availability zone
VPCs and Subnets
To get started with Amazon Virtual Private Cloud (Amazon VPC), you create a VPC and subnets. For a general overview of Amazon VPC, see What is Amazon VPC?.
VPC and Subnet Basics
A virtual private cloud (VPC) is a virtual network dedicated to your AWS account. It is logically isolated from other virtual networks in the AWS Cloud. You can launch your AWS resources, such as Amazon EC2 instances, into your VPC.
When you create a VPC, you must specify a range of IPv4 addresses for the VPC in the form of a Classless Inter-Domain Routing (CIDR) block; for example, 10.0.0.0/16
. This is the primary CIDR block for your VPC. For more information about CIDR notation, see RFC 4632.
- Set as default and Click on Next: Add Tags button
You can Add Amazon EBS Volume Types here.
Amazon EBS Volume Types
Amazon EBS provides the following volume types, which differ in performance characteristics and price, so that you can tailor your storage performance and cost to the needs of your applications. The volumes types fall into two categories:
SSD-backed volumes optimized for transactional workloads involving frequent read/write operations with small I/O size, where the dominant performance attribute is IOPS
HDD-backed volumes optimized for large streaming workloads where throughput (measured in MiB/s) is a better performance measure than IOPS
- Add Tags as much as you need and Click on Next: Configure Security Group button
- Enter Security group Name and Description
- Add HTTP and HTTPS Types
- Click on Review and Launch Button
Security Groups for Your VPC
A security group acts as a virtual firewall for your instance to control inbound and outbound traffic. When you launch an instance in a VPC, you can assign up to five security groups to the instance. Security groups act at the instance level, not the subnet level. Therefore, each instance in a subnet in your VPC could be assigned to a different set of security groups. If you don't specify a particular group at launch time, the instance is automatically assigned to the default security group for the VPC.
For each security group, you add rules that control the inbound traffic to instances, and a separate set of rules that control the outbound traffic. This section describes the basic things you need to know about security groups for your VPC and their rules.
You might set up network ACLs with rules similar to your security groups in order to add an additional layer of security to your VPC. For more information about the differences between security groups and network ACLs, see Comparison of Security Groups and Network ACLs.
- Review your configurations and Click on Launch button
- Select 'Create a new key pair' in dropdown menu
- Enter Name the Key pair name
- Click on Download Key Pair
- Click on Launch Instance
- Click on View Instance button
- Now your instance is running
You can see your instance details here.
Not I am going to access to my instance and create my web page.
Open your Terminal (Mac) or Console window (Windows).
and Navigate to the folder where the downloaded key pare file is.
The EC2KeyPair.pem.txt is the one I downloaded now.
MyEC2KeyPair.pem.txt is old one what I've used.
change permission of EC2KeyPair.pem.txt file
CHMOD 400 EC2KeyPair.pem.txt
Type ssh ec2-user@'your IPv4 Public IP' -I EC2KeyPair.pem.txt
Type yes
and then you can log in to your Amazon Linux Instance
Type sudo su
You are now with super user permission.
Type yum update -y to update Operation System
Type yum install httpd -y to install Apache Server
navigate to Web root page
cd /var/www/html
There is no file in the folder now.
I am going to my web page now.
Type nano index.html (or vi index.html)
I have created the web page as below to display my blog.
<html>
<h1> iframe - Changsoo's Blog - </h1>
<iframe id="blog"
title="Changsoo's Blog"
width="100%"
height="100%"
src="http://coronasdk.tistory.com">
</iframe>
</html>
Now I can see the index.html file in the folder.
I will start my Apache server.
service http start
Now enter 34.228.166.148 in URL bar in your browser then you can see the page below.
You can type my Public DNS (IPv4) to get the page in your browser as well.
http://ec2-34-228-166-148.compute-1.amazonaws.com/
Now I have my Amazon Linux server (EC2 instance) and public web page.
Termination Protection is turned off by default, you must turn it on.
If you want to terminate the instance then
1. Action - Instance Settings - Change Termination Protection
2. Click on Yes, Enable button.
On an EBS-backed instance, the default action is for the root EBS volume to be deleted when the instance is terminated.
EBS Root Volumes of your DEFAULT AMI's cannot be encrypted.
You can also use a third party tool (such as bit locker etc.) to encrypt the root volume, or this can be done when creating AMI's (lab to follow) in the AWS console or using the API.
'IoT > AWS Certificate' 카테고리의 다른 글
[AWS Certificate] Developer - Databases Overview & Concepts (0) | 2017.11.08 |
---|---|
[AWS Certificate] Developer - S3 Summary and Quiz (1) | 2017.11.07 |
[AWS Certificate] Developer - S3 Memo - from Cloud Guru Lecture (0) | 2017.11.03 |
[AWS Certificate] Developer - EC2 - Summary & Exam TIps (A Cloud Guru) (0) | 2017.10.18 |
[AWS Certificate] Developer - ELB, SDK and Lambda memo (0) | 2017.10.17 |
[AWS Certificate] Developer - AWS CLI memo (0) | 2017.10.12 |
[AWS Certificate] Developer - Security Group, Upgrading EBS Volume, EFS Lab memo (0) | 2017.10.05 |
[AWS Certificate] Developer - Associate EC2 (Elastic Compute Cloud) (0) | 2017.09.06 |
[AWS Certificate] Developer - Associate IAM (Identity and Access Management) (0) | 2017.09.04 |
[AWS Certificate] Developer - Associate overview memo (0) | 2017.08.31 |