March 20, 2024
Tamilarasu Gurusamy
We wil be deploying Apache Web Server with a simple html page on an EC2 instance using AWS Console
EC2 Page in Search Bar
Launch EC2 Instance Page
Launch Instance
buttonName for the EC2 Instance
Give a name for the EC2 Instance that will be deployed, as it can be used for reference later
AMI Selection
AMI is basically the Operating System that will be running on our EC2
Instance Types
t2.micro
Instance TypeCreate new key pair
Generate Key Pair
Create key pair
Key Pair
Allow SSH from
to get access of the shell of the EC2 instanceAllow HTTP traffic from the internet
, as we will need it to access the webpageStorage Options
User Data
#!/bin/bash
sudo apt update
sudo apt install apache2 -y
#!/bin/bash
sudo apt update
sudo apt install apache2 -y
EC2 Launch Completed
EC2 Instance Before Connect
Connect
button to proceedEC2 Instance Connect Page
Connect
button to proceedEC2 Instance Shell
Before Vim
Enter the following commands in the shell
Navigate to the directory /var/www/html
cd /var/www/html
cd /var/www/html
index.html
file ls
ls
Edit the index.html file using the favourite editor of your choice. I will be using Vim
Open index.html file using vim
sudo vim index.html
sudo vim index.html
Press i
to edit the file
Replace the existing contents of the index.html
file with the following html code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Web Page</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
text-align: center;
}
h1 {
color: #333;
font-size: 36px;
margin-bottom: 20px;
}
p {
color: #666;
font-size: 18px;
margin-bottom: 30px;
}
.button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
border-radius: 5px;
text-decoration: none;
transition: background-color 0.3s ease;
}
.button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Demo For EC2</h1>
<p>This is a demonstration of deployment of EC2 instances.</p>
<a href="#" class="button">Get Started</a>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Web Page</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
text-align: center;
}
h1 {
color: #333;
font-size: 36px;
margin-bottom: 20px;
}
p {
color: #666;
font-size: 18px;
margin-bottom: 30px;
}
.button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
font-size: 18px;
cursor: pointer;
border-radius: 5px;
text-decoration: none;
transition: background-color 0.3s ease;
}
.button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>Demo For EC2</h1>
<p>This is a demonstration of deployment of EC2 instances.</p>
<a href="#" class="button">Get Started</a>
</div>
</body>
</html>
Esc
and :x
to save and exit the vim sudo systemctl restart apache2
sudo systemctl restart apache2
Deployed Webpage
Terminate instance
option, which you can find in Instance State
option in this section