Lab 5 1: LAMP Stack in AWS Part 1 - nicolas-tullio/Tech-Journal GitHub Wiki
Deliverables
Screenshot of Apache Test Page (showing address bar with your EC2 DNS name)
Screenshot of PHPInfo page (showing EC2 Public DNS name in Browser)
Steps
Launch a new "free-tier" instance using Amazon Linux 2 image
Prepare the LAMP server
Connect to your instance via SSH.
- Make sure security group allows SSH
Run updates
sudo yum update -y
Install the lamp-mariadb10.2-php7.2 and php7.2 Amazon Linux Extras repositories
sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
Install the Apache web server, MariaDB, and PHP software packages
sudo yum install -y httpd mariadb-server
Start and enable the Apache web server
sudo systemctl start httpd
sudo systemctl enable httpd
Add a security rule to your Security Group to allow inbound HTTP (port 80)
Test your web server (Use public DNS address)
Set file permissions for EC2 users
sudo usermod -a -G apache ec2-user
- Log out and log back in to refresh the group
Change the group ownership of /var/www and its contents to the apache group.
sudo chown -R ec2-user:apache /var/www
To add group write permissions and to set the group ID on future subdirectories, change the directory permissions of /var/www and its subdirectories.
sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
To add group write permissions, recursively change the file permissions of /var/www and its subdirectories:
find /var/www -type f -exec sudo chmod 0664 {} \;
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
http://ec2-3-83-145-101.compute-1.amazonaws.com/phpinfo.php
Delete the phpinfo.php file
rm /var/www/html/phpinfo.php