Skip to content
David Galiata
Go back

Install Apache on AWS Linux EC2

Install Apache on AWS Linux EC2

Introduction

I recently performed testing with an AWS Application Load Balancer (ALB) and needed to spin up three web servers in EC2 quickly. I decided to use the option of passing “User Data” and run Linux commands at launch to install Apache.

This is a simple example, if you want to learn more, you can visit this link.

Install Apache

Prerequisites

The examples in this article assume the following:

The Process

After you have met all the prerequisites, go ahead and begin to launch your instance. Select all the details for your needs- Networking, Storage, etc. and navigate to the “Advanced details” section. Scroll down to locate the “User data” section and paste the following in the text field:

#!/bin/bash
yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd

The instance will now launch and run the commands to install Apache. When you log into the instance, you can check and confirm Apache is up and running by the following command:

Terminal window
service httpd status

For my testing purposes, I wanted to make sure I knew which web server I was hitting from the ALB. I went ahead and configured a simple web page with the following configuration steps:

Terminal window
sudo systemctl edit httpd
Terminal window
#add the following line to the config file
Directory "/var/www/html"
Terminal window
cd /var/www/html
sudo touch index.html
Terminal window
sudo vi /var/www/html/index.html

After the index.html file is saved, reload the web services:

Terminal window
sudo systemctl reload httpd

That’s it! Good luck with your testing!


Share this post:

Previous Post
SaaS Vendor Security Checklist
Next Post
Access Control Gaps Lead To Data Breaches