Skip to content

Instantly share code, notes, and snippets.

@devdilson
Last active May 31, 2021 15:56
Show Gist options
  • Save devdilson/1ddc899fb9b2dce8eb99d162af1432f5 to your computer and use it in GitHub Desktop.
Save devdilson/1ddc899fb9b2dce8eb99d162af1432f5 to your computer and use it in GitHub Desktop.
User data script for EC2 instance which install apache and creates a html page with Hello world message
#!/bin/bash
########################################
##### USE THIS WITH AMAZON LINUX 2 #####
########################################
# get admin privileges
sudo su
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo "Hello World from $(hostname -f)" > /var/www/html/index.html
@devdilson
Copy link
Author

#!/bin/bash
yum update -y
amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
yum install -y httpd mariadb-server
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 "" > /var/www/html/phpinfo.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment