Set-up an Apache2 web server on ubuntu 18.04 EC2 Instance AWS

Web servers are basically what the internet is comprised of, so in today’s post we will be learning “set-up an Apache2 web server“.

Before going further, make sure you know how to create an instance by checking out the following -> “Create an EC2 instance“.

Note: You have to carefully follow the upcoming steps, in order to get the expected result.

Step 1: Login into our EC2 instance.

login into the ubuntu ec2 instance
Login into the Ubuntu EC2 instance

Step 2: Update the repositories and upgrade your Ubuntu 18.04 EC2 instance.

aws ec2 ubuntu update and upgrade
AWS EC2 Ubuntu update and upgrade

Step 3: Installing Apache2 web server on our Ubuntu 18.04 EC2 instance.

aws ec2 ubuntu 18.04 install apache2 webserver
AWS EC2 Ubuntu 18.04 install Apache2 web server

Step 4: Checking whether we are able to access our web server by entering the IP address of our Ubuntu 18.04 EC2 instance into the URL bar of any web browser.

problem loading page
Problem Loading Page

Note: From above, the browser is showing “Problem Loading Page” in Apache2 web server.

Question: Why is it not showing the default page?

Answer: We have to further check other aspects about our instance:

  1. Whether the “apache2.service” is running or not.
  2. Do we have “Port 80” which is “Http Port” open or not by looking through our security group’s inbound rules.

To do so, follow the forthcoming steps.

Step 5: From the command below, we can see that the “apache2.service” is “active (running)“.

From here, we can see that the server is running as a service in on our Ubuntu 18.04 EC2 instance. We have to look further for the “port related problems“.

check whether apache2 is working or not on ec2 ubuntu
Check whether Apache2 is working or not on EC2 Ubuntu

Step 6: Checking the inbound rules from the EC2 dashboard, from below we can see that only the “PORT 22” is open, which is only for “SSH“.

Note: This means that we have to open port for “HTTP = Port 80” by adding an inbound rule to our Ubuntu 18.04 EC2 instance.

view inbound rules of an instance from ec2 dashboard
View Inbound Rules of an instance from EC2 dashboard

Step 7: Go to “Security Groups” in the EC2 dashboard and click on the “testing” which is the security group we want to edit inbound rules of, simply follow as shown in the picture below.

access security groups from aws ec2 dashboard
Access security groups from aws EC2 dashboard

Step 8: From the photo below, we can see that now we access to our “Security Group = testing“. Click on the “Edit” button in order to edit inbound rules.

edit inbound rules from ec2 dashboard
Edit Inbound Rules from EC2 dashboard

Step 9: Shown in the screenshot below, we have added the “HTTP Port = 80” to our inbound rules rules of “testing” security.

add http 80 port to ec2 instance
Add HTTP 80 port to EC2 Instance

Now, it is time to check again by accessing our web server.

Step 10: Access web server again by entering the IP address in the URL bar.

From the photo shown below, we can confirm that our web server is working and is accessible from the web browser as well.

apache2 ubuntu default page
Apache2 Ubuntu default page

Step 11: For further clarity, check again the “Inbound Rules” from EC2 dashboard, now as shown in the picture below, it is showing the previously added rule, which is “80/tcp” port for HTTP traffic.

confirm and view inbound rules for a ec2 instance
Confirm and view inbound rules for a ec2 instance

Comment here