DEV Community

Surav Shrestha
Surav Shrestha

Posted on

Install Apache Web Server in Amazon Linux EC2 Instance

Apache Web Server

Introduction

Installing a web server is a foundational step in web development and server management. Apache is one of the most popular web servers due to its reliability and extensive features. In this guide, we'll walk you through the steps to install and configure the Apache Web Server on an Amazon Linux AWS EC2 instance.

Prerequisites

Before we begin, ensure you have the following:

  1. An AWS account
  2. An EC2 instance running Amazon Linux

Step 1: Launch and Connect to EC2 Instance

For detailed instructions on launching and connecting to an AWS EC2 instance, you can refer to this article: Launch and Connect to AWS EC2 Instance.

Note: When launching the EC2 instance, leave the AMI (Amazon Machine Image) set to the default, which is Amazon Linux.

Step 2: Update Your Instance

Once connected to your EC2 instance, update the package lists:

sudo yum update -y
Enter fullscreen mode Exit fullscreen mode

Step 3: Install Apache Web Server

Now, install Apache (httpd is the Apache package for Amazon Linux) using the package manager (yum):

sudo yum install httpd -y
Enter fullscreen mode Exit fullscreen mode

Step 4: Start and Enable Apache

To start Apache and enable it to start on boot, use the following commands:

sudo systemctl start httpd
sudo systemctl enable httpd
Enter fullscreen mode Exit fullscreen mode

Step 5: Verify Apache Installation

You can verify that Apache is running by accessing your instance’s public IP address in a web browser:

http://ec2-18-208-219-229.compute-1.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

Amazon Linux Apache Default Page

You should see the default Apache2 Amazon Linux Default Page, indicating that Apache is successfully installed and running. πŸŽ‰

Conclusion

You’ve successfully installed and configured the Apache Web Server on your Amazon Linux AWS EC2 instance. This setup can now serve as the foundation for your web applications. 🌐

Additional Resources

If you have any questions or run into issues, feel free to leave a comment below.

Happy coding! πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Top comments (0)