Skip to content

Instantly share code, notes, and snippets.

@wamith
Last active November 5, 2016 22:04
Show Gist options
  • Save wamith/867b43fd71e6a2aeb990d80515d3ea63 to your computer and use it in GitHub Desktop.
Save wamith/867b43fd71e6a2aeb990d80515d3ea63 to your computer and use it in GitHub Desktop.
Install Apache, Mysql and PHP on a new AWS instance
#!/bin/bash
#update the server
echo "updating server, this might take some time ..."
sudo yum update -y
#install apache, php and mysql
echo "installing apache, php and mysql .."
sudo yum install -y httpd24 php56 mysql56-server php56-pdo php56-mysqlnd
#set php timezone, erros and do not expose it in the apache headers
echo "Editing php.ini .."
sed -i 's/\;date\.timezone\ \=/date\.timezone\ \=\ Europe\/Dublin/g' /etc/php.ini
sed -i '/^expose_php/c expose_php = Off' /etc/php.ini
sed -i '/^;error_log = php_errors.log/c error_log = \/var\/log\/php_errors.log' /etc/php.ini
#start mysql and apache
echo "Starting mysql and apache .."
sudo service mysqld start
sudo service httpd start
echo "Creating web folder .."
cd /var/
sudo groupadd www
sudo usermod -a -G www ec2-user
sudo chown -R root:www /var/www
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
mkdir /var/www/logs
chmod 777 /var/www/logs
#add mysql and apache to startup services
echo "adding apache and mysql to startup services .."
sudo chkconfig httpd on
sudo chkconfig mysqld on
echo "All done. Now you need to secure mysql."
echo "please run the secure install and follow the prompts: sudo mysql_secure_installation"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment