How to install Apache on AWS Instance

Rizaldi Satrya Herlambang
4 min readAug 31, 2020

Here are how:

  1. If you don't have the AWS account (or free tier account) yet, feel free to read my other article on how to create one, if all good let's start !!
  2. Log in to the AWS Dashboard and select EC2-choose instances
EC2 dashboard

3. Select the instances and click connect, for now, we can choose EC2 instances Connect

Select Connection

4. After that, we elevate our access by typing sudo su

5. Don't forget to update our apps by typing yum update -y, this -y means that we will select “yes” to all update as it is really important to keep all of our packages updated

Packages update

6. Once yum update is done, what we can do is start installing httpd, for this please type yum install -y httpd.x86_64

7. And then to start the service type: systemctl start httpd.service

8. and to ensure that the system remains enabled across reboots, we say enable httpd.service.

9. If we do: curl localhost:80, we should see this page

Curl Result

So, curl is basically to load whatever is in this URL, so if we do curl localhost:80, then we get this giant HTML page

10. And then let's try accessing this from the Public IP

11. So what do we get? a Time Out issue, that is because we have not set our Security Group, for this please open our inbound rules

We will see that the only allowed access are for TCP access using port 22, but as we see that our apache is using port 80 right?

Current Security Group

12. For this, we will add one more allowed access to our security group, by clicking on the name of our Security Group

And then click action and choose edit inbound rules

13. Click Add Rule and we add HTTP type access with source 0.0.0.0/0 which means anyone can connect, and then click save

We will then receive this upon successfully create our new rule

14. Now if we access our public IP again, we will see this page

15. The last thing to do is just to edit the page using the “Echo” command from our EC2 instance, for this we type echo “Whatever you want to type” > /var/www/html/index.html

After we refresh our webpage …. tadaaa it got updated to hungry something message

That’s it on how to install apache on AWS instance manually, in reality though, we usually automate this process by using the EC2 User Data, and we might link our public IP to some Legit DNS name using AWS Route 53.

Ahh right.. that might be our next article then. See you, stay curious and hungry :)

--

--