In this video, we explore how to use EC2 User Data scripts to automate server setup on Amazon Linux. You will also learn how to install and configure Apache (HTTPD), set directory permissions, manage service startup, and verify access through Linux firewall management using firewalld.
We also walk through practical command-line steps, including:
Installing and enabling Apache on Amazon Linux
Managing user and group permissions under /var/www
Starting and enabling firewalld
Adding and persisting HTTP service rules
Reboot verification and troubleshooting tips
This video is ideal for learners preparing for:
AWS Certified SysOps Administrator – Associate
AWS Certified Solutions Architect – Associate
AWS Certified Cloud Practitioner
CompTIA Linux+
LPIC-1 Linux Administrator
Red Hat Certified System Administrator (RHCSA)
By the end, you will have a working understanding of how to automate web server setup on EC2, manage permissions, and secure services using Linux firewalls.
UserData
#!/bin/bash
yum install -y httpd
systemctl start httpd
systemctl enable httpd
usermod -a -G apache ec2-user
chown -R ec2-user:apache /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} \;
find /var/www -type f -exec chmod 0664 {} \;
echo "Firewalls Rule" NOTALLOWEDNOTALLOWED /var/www/html/index.html
History
1 sudo netstat -tnlp
2 sudo yum -y install firewalld
3 firewall-cmd --state
4 sudo firewall-cmd --state
5 firewall-cmd --list-all
6 sudo systemctl start firewalld
7 sudo firewall-cmd --state
8 firewall-cmd --list-all
9 sudo firewall-cmd --list-all
10 sudo fillwall-cmd --zone=public --add-service http
11 sudo firewall-cmd --zone=public --add-service http
12 sudo firewall-cmd --list-all
13 sudo systemctl stop firewalld.service
14 sudo firewall-cmd --list-all
15 sudo systemctl start firewalld.service
16 sudo firewall-cmd --list-all
17 sudo firewall-cmd --zone=public --add-service http --permanent
18 sudo firewall-cmd --list-all
19 sudo systemctl stop firewalld.service
20 sudo systemctl start firewalld.service
21 sudo firewall-cmd --list-all
22 sudo reboot
23 sudo firewall-cmd --list-all
24 history