LAMP installation

The LAMP stack is well known because it is a web server on Linux, Apache, MySQL, and PHP. You can use the tutorial at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html to learn more about every command and configuration concept in LAMP. Please take a moment to read it.

The following command will install the LAMP stack and create a PHP settings page, for reference:

sudo yum update -y
sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd
sudo usermod -a -G apache ec2-user
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 {} ;
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

Now that we have configured our web server, assigned proper permissions, and created a configuration web page for PHP, let's allow public traffic ingress via HTTP, with the following configuration.

You can find the security group-id navigating from the instances list, details, and  associated security group, or directly from the security groups. Once it has been identified, copy the Group ID value, as shown in the following screenshot:

With the following command, we will authorize traffic ingress for our web server:

aws ec2 authorize-security-group-ingress --group-id sg-bddd92cb --protocol tcp --port 80 --cidr 0.0.0.0/0

Validate this change in the console; you will see it listed as the HTTP type, as shown in the following screenshot:

Navigate in your web browser by using the public IP address that was used before (in my case, 54.172.31.74). This should take you to the page shown in the following screenshot:

Verify the PHP Apache configuration, under 54.172.31.74/phpinfo.php, as shown in the following screenshot

The web page in the preceding screenshot confirms that we have successfully installed a web server using the LAMP stack on EC2.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.96.94