AWS-EC2 - Notes By ShariqSP
Amazon EC2 Overview
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. Below are the key features of Amazon EC2:
Features
- Instances: Virtual servers.
- Amazon Machine Images (AMIs): Preconfigured templates for your instances.
- Instance types: Various configurations of CPU, memory, storage, networking capacity, and graphics hardware.
- Key pairs: Secure login information for your instances.
- Instance store volumes: Storage volumes for temporary data.
- Amazon EBS volumes: Persistent storage volumes for your data.
- Regions, Availability Zones, Local Zones, AWS Outposts, and Wavelength Zones: Multiple physical locations for your resources.
- Security groups: A virtual firewall for your instances.
- Elastic IP addresses: Static IPv4 addresses for dynamic cloud computing.
- Tags: Metadata for your resources.
- Virtual private clouds (VPCs): Virtual networks isolated from the rest of the AWS Cloud.
Creating Ubuntu Instance
To create an Ubuntu instance on Amazon EC2, follow these steps:
- Sign in to the AWS Management Console.
- Navigate to the EC2 dashboard.
- Click on "Launch Instance".
- Choose an Amazon Machine Image (AMI) that contains Ubuntu.
- Select an instance type based on your requirements.
- Configure instance details like network settings, storage, etc.
- Review and launch the instance.
- Choose an existing key pair or create a new one for SSH access.
- Launch the instance.
Creating Windows Instance
The process for creating a Windows instance is similar to creating an Ubuntu instance, but you'll need to choose a Windows AMI and have the appropriate licensing.
Here are the basic steps:
- Sign in to the AWS Management Console.
- Navigate to the EC2 dashboard.
- Click on the "Launch Instance" button.
- Choose a Windows Amazon Machine Image (AMI).
- Select an instance type based on your requirements.
- Configure instance details, such as network settings and storage.
- Add any additional storage or tags if necessary.
- Configure security groups to control inbound and outbound traffic.
- Review and launch the instance.
- Choose an existing key pair or create a new one for RDP access.
- Click "Launch Instances."
Deploying a Simple Web Application with Apache2
Step 1: Launch an EC2 Instance
- Log in to your AWS Management Console.
- Navigate to the EC2 dashboard.
- Click on "Launch Instance" to create a new EC2 instance.
- Select an appropriate Amazon Machine Image (AMI), such as Ubuntu or Amazon Linux, and choose an instance type based on your requirements.
- Configure the instance settings, including network settings, storage, and security groups.
- Finally, launch the instance.
Step 2: Connect to Your EC2 Instance
- Once your instance is running, select it from the EC2 dashboard.
- Click on "Connect" to get instructions on how to connect to your instance using SSH.
Step 3: Install Apache2
- SSH into your EC2 instance using the provided instructions.
- Update the package index:
sudo apt update
- Install Apache2:
sudo apt install apache2
- Start the Apache2 service:
sudo systemctl start apache2
- Enable Apache2 to start on boot:
sudo systemctl enable apache2
Step 4: Deploy Your Web Application
- Navigate to the Apache2 web root directory:
cd /var/www/html
- Replace the default index.html file with your web application files.
Step 5: Access Your Web Application
- Copy the Public IP address or DNS name of your EC2 instance from the AWS Management Console.
- Paste the address into your web browser's address bar.
- You should now see your web application deployed and accessible over the internet.
Congratulations! You have successfully deployed a simple web application using Apache2 on an Amazon EC2 instance.