--Step 1. Create an EC2 Linux instance --Step 2. Prepare the web server --Step 3. Test the web server --Step 4. Create ALB and try to configure Multi AZ
Learn the following items
--What is EC2? --What is ALB? --Similar services to ALB, and their differences --What is Multi-AZ?
Amazon Elastic Compute Cloud (Amazon EC2)
EC2 is a "virtual server" provided by AWS. You can prepare an environment where you can immediately run virtual servers of various OS such as Linux, Windows, and Red Hat.
EC2 can be built in units called instances. There are multiple types of instances. For example, in the case of a small type instance, the CPU and memory are fixed, such as CPU1 and memory 1GB. It is not possible to add only CPU or only memory, and if you want to increase the specifications, you need to change the instance type. (Like small → medium)
ALB (Application Load Balancer) is a part of the system called AWS (Amazon Web Services) provided by Amazon.com, and is a load balancing service that distributes the load generated by Web services.
ELB is an abbreviation of "Elastic Load Balancing", and this ELB was originally a load balancing service on AWS. However, when ALB was later developed as an additional option, ELB would change its name to "Classic Load Balancer (CLB)". And ELB came to be used as a general term for the services of ALB and CLB.
--Behavior on layer 7 (application layer) --New support for WebSocket and HTTP / 2 --For the latest application architecture --Can route to target group --Using multiple Availability Zones
ALB has many distinctive features compared to CLB, and has the charm of ALB.
Assumption: What is Availability Zone?
A data center that is physically separated within each region (Tokyo, Oregon, Frankfurt, etc.). In the Tokyo region
- ap-northeast-1a
- ap-northeast-1b
- ap-northeast-1c
There are three Availability Zones. Also, it seems that the region of user A and the region of user B are not always the same.
What is Multi-AZ
Build an application for one AZ (EC2, RDS, etc.) For Single-AZ Building for multiple AZs is often called Multi-AZ.
Public and private keys are called key pairs. Amazon EC2 uses public key cryptography to encrypt and decrypt your login information. Public key cryptography uses a public key to encrypt data, and recipients use a private key to decrypt data. Amazon EC2 stores only public keys, and users store private keys. Users must specify a private key when sshing to the instance.
Added TCP / 80, TCP / 22 to inbound rules
--TCP / 80: Rule to allow HTTP communication (Source: set "0.0.0.0/0") --TCP / 22: Rule to allow ssh connection (Source: set "My IP"). The IP address you are currently accessing The dress is set automatically
Select instance type t2.micro
Enable default VPC, default Subnet, and auto-assigned public IP
No particular changes
Select a pre-created security group
In the key pair selection pop-up, select "Select existing key pair" and select the created key pair name.
Select "Instance" in the left pane and check the status of the instance being created.
Refrain from public DNS (IPv4) for ssh connection Example.) Ec2-18-183-224-68.ap-northeast-1.compute.amazonaws.com
Type the following code on TeraTerm connected by SSH
$ sudo yum -y update
$ sudo amazon-linux-extras install -y php7.2
$ sudo yum install -y httpd
$ sudo systemctl start httpd
$ sudo systemctl enable httpd
Example.) Ec2-52-193-98-49.ap-northeast-1.compute.amazonaws.com
Check the document root and port from the Apache configuration file /etc/httpd/conf/httpd.conf
--DocumentRoot: DocumentRoot "/ var / www / html"
--Listing port: Listen 80
$ echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
Example.) Http://ec2-52-193-98-49.ap-northeast-1.compute.amazonaws.com/phpinfo.php
$ rm /var/www/html/phpinfo.php
<html>
<head>