Launching an Apache Web Server on an AWS EC2 Instance with User Data

I wanted to have an Apache Web Server served up on EC2. Rather than sorting the web server after the EC2 was launched, I used user data and other configurations so that at the point of the EC2 launch, the web server would function. Steps are below.
- Go to EC2 Dashboard and launch an instance in the upper righthand corner (Image 1)

- Select Amazon Linux 2 AMI (Image 2)

- I chose t2.micro because it was free and adequate (Image 3)

- Enter the following commands in the user data (Yellow box in Image 4). These will make necessary updates to the environment, install Apache, start & enable the web server, and title the landing page.
#!/bin/bash
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo “Hello from Kevin’s Apache Server served up on AWS EC2”

- Add storage: Keep as default
- Add tags (Image 5)

- Open necessary ports in Security Groups (Image 6)

- Review Instance Launch: Looks good, ready for launch. (Image 7)

- View launch status (Image 8). To have the instance up and running may take a minute or two.

- In EC2 instances, view that the instance is running (Image 9). Then click the Instance ID to get a snapshot of the EC2.

- In the EC2 Instance, copy the Public IPv4 address (Image 10)

- Paste the address in another window to test the web server. Image 11 confirms that it worked & the mission was complete!
