Type something to search...
How to Install Apache Web Server on Amazon Linux 2

How to Install Apache Web Server on Amazon Linux 2

Introduction

In this tutorial, we will learn how to install Apache web server on Amazon Linux 2. We will also learn how to configure Apache web server to run simple HTML web page.

Prerequisites

To follow this tutorial, you will need:

  • An Amazon Linux 2 EC2 instance.
  • A user with sudo privileges.

Install Apache Web Server and run simple HTML web page

Step 1: Install Apache Web Server

Before we start, we need to update the package list and upgrade the installed packages:

Terminal window
sudo yum update -y

Now, we can install Apache web server:

Terminal window
sudo yum install httpd -y

Step 2: Start Apache Web Server

Now, we can start Apache web server:

  • Start Apache Server
Terminal window
sudo systemctl start httpd
  • Configure Apache to run on system boot
Terminal window
sudo systemctl enable httpd

Step 3: Configure Firewall

Now, we need to configure the firewall to allow HTTP traffic:

Terminal window
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

Step 4: Create a Simple HTML Web Page

Before we can test Apache web server, we need to change the permissions of the /var/www/html directory:

Terminal window
sudo chmod 777 /var/www/html

Now, we can create a simple HTML web page:

Terminal window
sudo vi /var/www/html/index.html
<!doctype html>
<html>
<head>
<title>Apache Web Server</title>
</head>
<body>
<h1>Apache Web Server</h1>
<p>This is a simple HTML web page.</p>
</body>
</html>

Step 5: Test Apache Web Server

Now, we can test Apache web server by opening the public IP address of our Amazon Linux 2 EC2 instance in a web browser:

Apache Web Server

Conclusion

In this tutorial, we learned how to install Apache web server on Amazon Linux 2. We also learned how to configure Apache web server to run simple HTML web page.

References

Related Posts

Check out some of our other posts

Git SSH Keys for GitHub, GitLab, and Bitbucket on Linux

Git SSH Keys for GitHub, GitLab, and Bitbucket on Linux

Introduction Git connects to remotes by default via HTTPS, which requires you to enter your login and password every time you run a command like Git pull or git push, using the SSH protocol. You m

read more
Dotfiles: A Git-Based Strategy for Configuration Management

Dotfiles: A Git-Based Strategy for Configuration Management

Keeping your dotfiles β€” those hidden configuration files that dot your home directory β€” both safe and easily accessible across various machines can seem daunting. However, with the strategy outlined b

read more
How To Create A Custom VPC Using AWS CLI

How To Create A Custom VPC Using AWS CLI

Introduction In the sample that follows, an IPv4 CIDR block, a public subnet, and a private subnet are all created using AWS CLI instructions. You can run an instance in the public subnet and conn

read more
Introduction to Linux CLI

Introduction to Linux CLI

Introduction The Linux operating system family is a group of free and open-source Unix systems. They consist of Red Hat, Arch Linux, Ubuntu, Debian, openSUSE, and Fedora. You must utilize a shell

read more
VIM Cheat Sheet

VIM Cheat Sheet

What Is VIM? VIM (Vi Improved) is a versatile text editor pre-installed on most Linux systems, known for its efficiency in command-line file editing. Its modal natureβ€”switching between modes like

read more
How to Install and Setup FireWall on Amazon Linux 2

How to Install and Setup FireWall on Amazon Linux 2

Introduction We will learn how to install and setup FireWall on Amazon Linux 2 in this tutorial. We will also discover how to set up FireWall so that it functions with the Amazon Linux 2. Prer

read more