Lab 5‐1 ‐ LAMP Stack in AWS ‐ Part 1 - Isaiah-River/SYS-360 GitHub Wiki

Navigation

Overview

In this lab, I set up a basic LAMP stack, and ran a quick test to show myPHP working correctly.

Objectives

Completing the lab

Part 01 - Setting up an instance

To start this lab I prepared a lamp server by booting into the Amazon Learners Lab and starting a new "free-tier" instance using Amazon Linux 2 image. I made sure to select my key and security group before starting the instance. I opened a console, and navigated to where my security key was, and ran the command ssh -i "isaiahriver.pem" [email protected] to remotely connect to my instance. Once in, I ran the command sudo yum update -y to ensure my software packages were up to date.

image

I then prepared my instance for my lamp server with the following commands:

# Install 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 Apache web server, MariaDB, and PHP software packages
sudo yum install -y httpd mariadb-server

# Start the Apache web server
sudo systemctl start httpd

# Configure Apache for boot on a system startup
sudo systemctl enable httpd
sudo systemctl is-enabled httpd

With these packages installed, and my Apache server up, I went to my security group and enabled inbound HTTP connections. I then connected opened a browser and connected to my address at http://98.81.253.67/.

image

After this I adjusted ec2-user's group to allow for them to modify the Apache server by running the command sudo usermod -a -G apache ec2-user. I then logged out and back in, and ran the command groups to ensure that the Apahce group was listed:

image

I then adjusted the ownership of the /var/www directory with the command sudo chown -R ec2-user:apache /var/www I then adjusted the write abilities for the directory and its subfolders with the following commands:

sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;

find /var/www -type f -exec sudo chmod 0664 {} \;

I then took a screenshot of my up and running Apache webpage for my first deliverable:

image

Part 02 - Testing my LAMP server

For this next part, I began testing my LAMP server. I started by creating a PHP file within my web server by running the command echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php, and then navigated to http://ec2-98-81-253-67.compute-1.amazonaws.com/phpinfo.php from my web browser. I took a screenshot for my second deliverable:

image

I cleaned up my web server by removing my PHP file with the command rm /var/www/html/phpinfo.php before moving on to the next lab.