Lab 5 1 LAMP Stack in AWS Part 1 - max-gallagher/SYS-360 GitHub Wiki
Step 1: Prepare the LAMP server
-
Create a new EC2 Instance, using Amazon Linux 2, in this case I named it "5-1 LAMP" and it uses the same key and security group we have bee nusing in class
-
Connect through SSH then run yum updates with
ssh -i "private-key" ec2-user@"instance-ip"
andsudo yum update -y
-
Install the lamp-mariadb 10.2-php7.2 and php 7.2 Amazon Linux Extras repositories.
sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
-
Install Apache, MariaDB, and PHP
sudo yum install -y httpd mariadb-server
-
Start and enable httpd using systemctl
-
Add a security rule to your Security Group to allow inbound HTTP
- Test to see if it works
- Add EC2-user to the apache file group so it has permission to edit apache files
sudo usermod -a -G apache ec2-user
- Change the group ownership of /var/www/ to the apache group
sudo chown -R ec2-user:apache /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 {} \;
Step 2: Test your LAMP server
- Create a PHP file in the Apache document root
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
- Navigate to the URL of the file in your web browser
- Delete the phpinfo.php file, this was just made to ensure everything is working and should not be kept public due to security reasons
rm /var/www/html/phpinfo.php
Deliverables
SUBMIT: Screenshot of Apache Test Page (showing address bar with your EC2 DNS name)
SUBMIT: Screenshot of PHPInfo page (showing EC2 Public DNS name in Browser)