Skip to content

Instantly share code, notes, and snippets.

@skellertor
Last active September 8, 2015 22:15
Show Gist options
  • Save skellertor/35f3f5d8e36320c012e9 to your computer and use it in GitHub Desktop.
Save skellertor/35f3f5d8e36320c012e9 to your computer and use it in GitHub Desktop.
Shell script for setting up apache for amazon linux ec2 instance
#!/bin/bash
# Setting up LAMP stack amazon linux
# Install all updates without asking permission
sudo yum update -y
# Install the Apache web server, MySQL, and PHP software packages
sudo yum install -y httpd24 php56 mysql55-server php56-mysqlnd
# Start the Apache web server
sudo service httpd start
# Configure the Apache web server to start at each system boot.
sudo chkconfig httpd on
# Verify that httpd is on by running the following command.
chkconfig --list httpd
# Add the www group to your instance.
sudo groupadd www
# Add your user (in this case, ec2-user) to the www group.
sudo usermod -a -G www ec2-user
# Change the group ownership of /var/www and its contents to the www group.
sudo chown -R root:www /var/www
# Change the directory permissions of /var/www and its subdirectories to add group write permissions and to set the group ID on future subdirectories.
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} +
# Recursively change the file permissions of /var/www and its subdirectories to add group write permissions.
find /var/www -type f -exec sudo chmod 0664 {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment