Once you’re connected to your Amazon Linux 2 instance, follow these steps to deploy the application.
To ensure all your software packages are up to date, execute the following command:
sudo yum update -y
Install lamp-mariadb10.2-php7.2 and php7.2 using Amazon Linux Extras to get the latest LAMP MariaDB and PHP packages for Amazon Linux 2.
sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
If you encounter the error message sudo: amazon-linux-extras: command not found
, it means your instance was launched with the Amazon Linux AMI instead of Amazon Linux 2. You can check your instance type using the following command:
```bash
cat /etc/system-release
```
Install Apache web server, MariaDB, and PHP packages.
sudo yum install -y httpd mariadb-server
Start the Apache web server.
sudo systemctl start httpd
Configure the Apache web server to start on system boot.
sudo systemctl enable httpd
Verify that httpd is enabled by running the following command:
sudo systemctl is-enabled httpd
In the EC2 interface:
Paste the Public IPv4 address into your browser to test Apache.
Execute the following commands to grant permissions:
sudo usermod -a -G apache ec2-user
- Change the ownership of the **/var/www** directory and its contents to the apache group.
```bash
sudo chown -R ec2-user:apache /var/www
```
- To add group write permissions and set group IDs on future subdirectories, change the directory permissions of **/var/www** and its subdirectories.
```bash
sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
```
- To add group write permissions, recursively change the permissions for the files in **/var/www** and its subdirectories:
```bash
find /var/www -type f -exec sudo chmod 0664 {} \;
```