-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash -xe | ||
|
||
|
||
# System Updates | ||
sudo yum -y update | ||
|
||
|
||
# STEP 1 - Install system software - including Web and DB | ||
sudo yum install -y mariadb-server httpd | ||
sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2 | ||
|
||
|
||
# STEP 2 - Web and DB Servers Online - and set to startup | ||
sudo systemctl start httpd | ||
sudo systemctl enable httpd | ||
sudo systemctl start mariadb | ||
sudo systemctl enable mariadb | ||
|
||
|
||
# STEP 3 - Setpassword & DB Variables | ||
DBName='HR_RDS_DB' | ||
DBUser='admin' | ||
DBPassword='Project8' | ||
DBRootPassword='Admin123root' | ||
DBEndpoint='copy_here_rds_endpoint' | ||
|
||
|
||
# STEP 4 - Set Mariadb Root Password | ||
mysqladmin -u root password $DBRootPassword | ||
|
||
|
||
# STEP 5 - Install Wordpress | ||
sudo wget http://wordpress.org/latest.tar.gz -P /var/www/html | ||
cd /var/www/html | ||
sudo tar -zxvf latest.tar.gz | ||
sudo cp -rvf wordpress/* . | ||
sudo rm -R wordpress | ||
sudo rm latest.tar.gz | ||
|
||
|
||
# STEP 6 - Configure Wordpress | ||
sudo cp ./wp-config-sample.php ./wp-config.php | ||
sudo sed -i "s/'database_name_here'/'$DBName'/g" wp-config.php | ||
sudo sed -i "s/'username_here'/'$DBUser'/g" wp-config.php | ||
sudo sed -i "s/'password_here'/'$DBPassword'/g" wp-config.php | ||
sudo sed -i "s/'localhost'/'$DBEndpoint'/g" wp-config.php | ||
|
||
# Step 6a - permissions | ||
sudo usermod -a -G apache ec2-user #Add your user (in this case, ec2-user) to the apache group. | ||
sudo chown -R ec2-user:apache /var/www #Change the group ownership of /var/www and its contents to the apache group. | ||
sudo chmod 2775 /var/www | ||
|
||
sudo find /var/www -type d -exec chmod 2775 {} \; | ||
sudo find /var/www -type f -exec chmod 0664 {} \; | ||
|
||
# STEP 7 Create Wordpress DB | ||
echo "CREATE DATABASE $DBName;" >> /tmp/db.setup | ||
echo "CREATE USER '$DBUser'@'localhost' IDENTIFIED BY '$DBPassword';" >> /tmp/db.setup | ||
echo "GRANT ALL ON $DBName.* TO '$DBUser'@'localhost';" >> /tmp/db.setup | ||
echo "FLUSH PRIVILEGES;" >> /tmp/db.setup | ||
mysql -u root --password=$DBRootPassword < /tmp/db.setup | ||
sudo rm /tmp/db.setup |