Installing Apache web server on AWS EC2 instance, a use case.

Dayo Ogunnoiki

--

This project seeks to install a web server for a Level Up Bank, but the bank now needed a website that customers could interact with — it needed a dynamic website. Apache is a fine choice for a web server because it is secure, reliable, scalable, customizable, and open source. For this project, I want to make use of a AWS EC2 instance. For the purpose of the bank, the instance will have security features from Red Hat Enterprise Linux (RHEL) as well as its enterprise orientation — but without the subscription cost more so, RHEL is more intentionally aligned with the needs of businesses.

The following are the steps through the process of installing the Apache web server on a AWS EC2 instance, including setting up a Security Group and Key Pair for the EC2 instance, using user-data.

It then shows how to create a custom web page that displays a unique message on the EC2 instance.

Step One: Launch an Instance.

We shall begin our journey by logging into the AWS Cloud Console. Then search EC2, this will take us to the EC2 dashboard, at the Dashboard, we select the EC2 console to launch the instance.

We name our instance and select a machine, which would be Linux. We leave most tabs as free default. We then create a key pair, edit network settings, and enable public IP. After creating a key pair for connecting to my instance, I needed to configure my network settings. For this project, I allowed SSH traffic from anywhere. I allowed traffic from HTTP because, although it lacks the security of HTTPS, it also lacks cost and setup. Under security group, I selected existing security group-web access and then launched the instance. A green success banner shows afterwards.

Selecting our machine to launch the instance.
Configuring Network settings.

Next part of our journey is to allow SSH into the deployed EC2. This is done by connecting to the EC2 instance.

Connecting to the Instance.

Having launched the instance, the next step was to connect to it through the command line. After connecting, since it was a new instance, the first command I made was to (1) update the packages to their latest versions.

1. I updated the packages with this command; sudo yum updated -y

2. Then, I installed the Apache HTTP server9httpd) with this command; sudo yum install -y httpd

3. Then I started the server with : sudo systemctl start httpd.service

4. sudo systemctl enable httpd.service

5. Finally, we were to display the message “Hello,Welcome to Level Up Bank , Gold Team” on the webpage. I was able to achieve this with this command line:

6. [root@ip-172–31–42–228 ec2-user]# echo “Hello, Welcome to level up Bank, Gold team” > /var/www/html/index.html.

When I copied the public Ip address and pasted it on a web browser the result is displayed as in the snapshot.

--

--