How to launch EC2 Instance ? How to deploy a webpage on Ec2 Instance?
Amazon web Services
- It is public cloud service provider launched in 2006.
- It provides over 175 services related to compute, storage, networking, CDN(cloud delivery network), ML(Machine learning), IoT(Internet of Things).
- Services accessible from anywhere, anytime, on a pay as go pricing model.
- It provides web based management console, CLI and SDK.
- It provides more functionality than any other CSP(cloud service Provider).
- It has Fastest pace of innovation.
- It has more security, scalability, reliability.
According to survey in 2020, AWS is at top of Cloud Service Provider.
AWS Compute service :
A) Amazon EC2 :
- It provides Scalable computing capacity.
- you can launch as many or as few virtual servers as you need.
- configure security and networking.
- manage storage.
Amazon EC2 Features :
- Amazon Machine Image(AMI) :-
→ It is a template that defines the Operating System and additional applications for your servers.
→ AWS provides many AMIs. you can also create your own custom AMI.
AMI helps you to quickly launch new servers .
2. Instance Type : -
It defines Configuration of CPU, Storage, RAM and networking Performance of EC2.
These instance types have been categories into different categories such as general purpose, compute optimized and memory optimized based on use case.
3. Key pairs :
→ public key is stored by AWS and private key you have to store in a secure place.
- we can use private key instead of password to securely access our instances.
- when we try to connect instance via SSH connection so we need to provide private key.
- In case , we lost private key, we can’t recovered it.
4. Instance Store Volumes :
- It is temporarily storage. once you stop or terminate your instance your data will lost.
- This storage is physically attached to your instance.
- It is ideal for information that changes frequently such as caches, buffers, scratch data.
5. Amazon EBS volumes :
- It is persistence storage volume by AWS for EC2 instance.
- It can be mounted as device to your EC2 instance.
- Data would not lost once your instance will be terminated.
- File system can be created on these devices or they can be used as drives.
- It should be used for quickly accessing the data as there a very fast devices.
6. Regions and availability Zone(AZ) :
- AWS has the concept of a Region, which is a physical location around the world where we cluster data centers. We call each group of logical data centers an Availability Zone.
- Each AWS Region consists of multiple, isolated, and physically separate AZs within a geographic area.
- An Availability Zone (AZ) is one or more discrete data centers with redundant power, networking, and connectivity in an AWS Region.
- An AZ has more than one data centers.
- you can launch Amazon Ec2 in regions and AZs of your choice from anywhere.
7. Security groups :
- It allows to configure security for Amazon Ec2 , who can access content from it or who can’t .
- It allow you to define ports , protocols and IP ranges that can reach out to your instance.
- To control incoming traffic inbound rules and controls outbound traffic outbound rules are there.
- You can Modify security groups .
7. Elastic IP address :
- It provides static public IPv4 addresses for dynamic cloud computing.
- The IPs can be attached to EC2 instances.
- Elastic IP can be quickly remaps to new instance , if your current Ec2 Instance fails.
- Its metadata that you can define your Amazon EC2 resources.
9. Amazon VPC :
- It helps you to define in which Amazon VPC you want to launch your instance.
Creating an Ec2 Instance and deploying a web page on Apache web server : -
Step 1. Select your region
Step 2. Go to services and click on compute then click on EC2 :
You will see this type of screen i.e. EC2 dashboard.
You can see in this below image , In Mumbai there are 3 Availability zone i.e.
ap-south-1a, ap-south-1b, ap-south-1c.
Step 3. Launch Ec2 instance by clicking on Launch button in Ec2 Dashboard :
Step 4. Filling details
a) Fill name to your Instance
In my case I named DemoEc2Instance.
b). Select AMI(Amazon Machine Image)
To Know about AMI just read above .
I have selected Amazon Linux 2 AMI(Free tier eligible).
c). Select Instance Type :
I m selecting instance type as t2 micro.
Step 5. Create Key pair:
To securely connect to your instance .
click on create new key pair.
You will get this prompt then select options as your convenience and give a name to your key pair.
After clicking on Create key pair , automatically key pair will be downloaded in your system that will help in time of connecting to instance.
Step 6. select key-pair :
Step 7. Configure Network setting :
I am allowing SSH and HTTP.
Step 8. Configure Storage :
As of Now I am allocating 8 Gb as Storage.
Step 9. Click on Launch Instance :
After launching the instance then get back to Ec2 dashboard then click on instance , You will this type of Screen, there your instance is Running.
Step 10. Connecting to your instance via putty.
select your instance then click on connect then you will get this screen.
you can see here public IP address via that you can connect via SSH or putty.
What is putty?
Putty is program to login to Linux via SSH .
Put public IP address in Host Name.
then go to connection → SSH → Auth → Put your key pair here from your file system.
After that you will get this screen. then login as : ec2-user
then you can run any command of Linux in terminal.
Step 11. Deploying a webpage In Apache Webserver :
Step 1. login as root user
Step 2. Install apache webserver :
by using this command :
$ yum install httpd -y
Step 3. Change directory to var/www/html
$ cd /var/www/html
Step 4. create a html file and put your code
$ vi index.html
Step 5. Start apache webserver :
$ systemctl start httpd
Now you can access your page through your browser using your public ip
You can see my web app in below image :
thank you …