what is HTTPD? How to install httpd on Amazon linux2 and run your custom web page
Table of contents
- what is HTTPD?
- How to install httpd on Amazon linux2 and run your first web page
- Connect to your Amazon Linux 2 instance using SSH.
- Update package lists by running the following command:
- Install httpd using the package manager (yum) by running the following command:
- After the installation completes, start the httpd service:
- Enable httpd to start automatically on system boot:
- Next to run your custom web page
what is HTTPD?
httpd
refers to the Apache HTTP Server, an open-source web server software that powers a significant portion of websites on the internet. It provides the infrastructure to deliver web content over the HTTP protocol.
Imagine you have a computer, and you want to show a website to other people on the internet. But for that to happen, you need a special program that helps your computer communicate with their computers. That's where httpd
comes in.
httpd
, which stands for Hypertext Transfer Protocol daemon, is like a helpful messenger that carries information between your computer and other computers on the internet. It's a special piece of software that runs on a computer and allows it to share web pages with other people.
When you visit a website, your web browser sends a request to the httpd
program running on the website's computer. It asks for the web page you want to see. The httpd
program then fetches that web page from its storage and sends it back to your browser, so you can see it on your screen.
Think of httpd
as the friendly middleman between your computer and the website's computer. It ensures that the web page you want is delivered to your computer, so you can enjoy reading articles, looking at pictures, or watching videos on the internet.
Now let's see the difference between httpd and https
HTTP (Hypertext Transfer Protocol): HTTP, or
httpd
, is the protocol used for transferring data between a web server and a web browser. It operates on port 80 and is widely used for regular web traffic. However, it does not provide encryption or secure data transmission, which means that the information exchanged between the server and the browser can potentially be intercepted or modified by attackers.HTTPS (Hypertext Transfer Protocol Secure): HTTPS, or
https
, is an extension of HTTP that incorporates encryption and security measures to protect data transmitted between the web server and the browser. It operates on port 443 and uses SSL/TLS (Secure Sockets Layer/Transport Layer Security) protocols to establish a secure connection. The encryption ensures that the information exchanged, such as login credentials, personal data, or financial details, remains confidential and cannot be easily intercepted or tampered with.
In summary, while both httpd
and https
are protocols used for web communication, httpd
is the regular unencrypted version of the protocol, while https
is the secure, encrypted version that safeguards sensitive information. https
is commonly used for websites that handle sensitive data, such as e-commerce platforms, online banking, or any situation where data privacy and security are crucial.
How to install httpd on Amazon linux2 and run your first web page
To install httpd
on Amazon Linux 2, you can follow these step-by-step instructions:
If you want to know how to lanuch EC2 instance in AWS. Please refer to this below link
What is EC2 in AWS and how to launch an EC2 instance? (hashnode.dev)
Connect to your Amazon Linux 2 instance using SSH.
Update package lists by running the following command:
sudo yum update -y
Install
httpd
using the package manager (yum
) by running the following command:
sudo yum install httpd -y
After the installation completes, start the
httpd
service:
sudo systemctl start httpd
Enable
httpd
to start automatically on system boot:
sudo systemctl enable httpd
Configure Security Groups and Firewall Configure your instance's security groups or firewall settings to allow incoming HTTP traffic on port 80. This step ensures that your blog is accessible to visitors.
Next to run your custom web page
In the case of the Apache HTTP Server (httpd), the path to add files depends on the operating system and the specific configuration of your server. By default, Apache serves files from a directory called the "DocumentRoot," which is specified in the server's configuration file.
The location of the configuration file also varies based on the operating system. In general, you can find the main configuration file named "httpd.conf" or "apache2.conf" (or similar) in the Apache installation directory or within a directory like /etc/httpd/
or /etc/apache2/
.
Within the configuration file, you'll typically find a directive called "DocumentRoot" that specifies the path to the directory from which Apache serves files. For example, it might look like this:
DocumentRoot /var/www/html
In the above example, the path is /var/www/html
, but it can be different depending on your server's configuration. You can add your files to this directory or any subdirectory within it, and Apache will serve them when requested.
Create index.html file in the above path.
sudo vi index.html
Use the below code to run your custom web page
<!DOCTYPE html>
<html>
<head>
<title>Stay Motivated</title>
<style>
body {
background-color: #f2f2f2;
color: #333;
font-family: Arial, sans-serif;
text-align: center;
padding: 50px;
}
h1 {
font-size: 36px;
margin-bottom: 20px;
}
p {
font-size: 18px;
line-height: 1.5;
margin-bottom: 30px;
}
.quote {
font-size: 24px;
font-style: italic;
margin-bottom: 10px;
}
.author {
font-size: 18px;
}
.button {
display: inline-block;
background-color: #007bff;
color: #fff;
font-size: 24px;
padding: 10px 20px;
border-radius: 5px;
text-decoration: none;
transition: background-color 0.3s ease;
}
.button:hover {
background-color: #0056b3;
}
</style>
</head>
<body>
<h1>Stay Motivated</h1>
<p>Find inspiration and keep pushing towards your goals.</p>
<div class="quote">
"The future belongs to those who believe in the beauty of their dreams."
</div>
<div class="author">- Eleanor Roosevelt</div>
<p>Never give up. Your dreams are worth pursuing!</p>
<a href="#" class="button">Embrace the Journey</a>
</body>
</html>
By default httpd work on port no.80
#to access the webserver
http://system_ip:80
Now, you will see your custom webpage ๐
If this post was helpful, please do follow and click the clap ๐ button below to show your support ๐
_Thank you for reading
-Praveen
Subscribe to my newsletter
Read articles from Praveen directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by