Skip to content

Instantly share code, notes, and snippets.

@jeffbrl
Last active August 8, 2023 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffbrl/04252568bf9ff33c700a32181d3d46b1 to your computer and use it in GitHub Desktop.
Save jeffbrl/04252568bf9ff33c700a32181d3d46b1 to your computer and use it in GitHub Desktop.
AWS EC2 User Data for installing apache on Amazon Linux 2
#!/bin/bash -xe
yum update -y
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 `hostname` > /var/www/html/index.html
echo '<br><br>' >> /var/www/html/index.html
# create ~ 12K of random text
base64 /dev/urandom | head -c 1000 >> /var/www/html/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment