Getting you Ec2 Instance set-up correctly from the outset saves you hours of keyboard smashing!
PHP has been evolving rapidly lately, the current iteration is 7.4 and version 8 is not too far away.
One of the challenges with these welcomed updates, is trying to keep up with them!
How to Install LAMP with PHP 7.2 on your AWS Ec2 Linux 2 Instance
Currently, the latest available version of PHP on AWS Linux 2 image is 7.4 (March 2021)
Installation can be quick and painless with these steps:
Access your Ec2 via your favourite tool, such as Putty.
$~ sudo su
$~ yum update -y
$~ amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
$~ yum install -y php73-gd php73-xml php73-xmlrpc php73-mcrypt php-pear
How to Install Apache 2.4 web-Server on your Ec2 Instance
Follow-up your PHP installation by installing Apache to get your web server up & running
$~yum install -y httpd mariadb-server
$~ systemctl start httpd
$~ systemctl enable httpd
$~ systemctl is-enabled httpd
How to Install Composer on your Ec2 Instance
Follow-up your PHP & Apache installation by Composer
$~ curl -sS https://getcomposer.org/installer | php
$~ mv composer.phar /usr/bin/composer
$~ chmod +x /usr/bin/composer
How to Install Laravel Requirements
Prepare your Installation for Laravel
$~ yum install php-mbstring -y
$~ yum install php-xml
$~ sudo systemctl restart httpd
$~ sudo systemctl restart php-fpm
Clone your Laravel Project from Git
Install your project
$~ cd /var/www/html
$~ git clone <repo-url>
$~ mv /var/www/html/<repo-dir-name>/* /var/www/html/
$ mv /var/www/html/<repo-dir-name>/.* /var/www/html/
$ rmdir /var/www/html/<repo-name>