Deploying a PHP application connected to MySql database using AWS EC2 instance and RDS with MySQL database engine
Create a Simple Database App: Connecting to MySQL with PHP
- Create a S3 bucket to store the application source code
- Launch an EC2 instance, assign instance profile role and use the User Data to install the webservers and dependecies at launch of EC2
- #!/bin/bash sudo yum update -y sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2 sudo yum install -y httpd mariadb-server sudo systemctl start httpd sudo systemctl enable httpd sudo systemctl is-enabled httpd sudo aws s3 cp s3://dynamic-website-2-tolu --region us-east-2 /var/www/html/ --recursive
- Create a RDS database and use Mysql engine, ensure high availability: Multi-AZ deployment
- Take note of the Database Endpoint and port 3306 to be configured with the web app
- Create a security group and ensure its only open to the web server
- EC2 instance
- RDS (MySQL)
- Elastic Load Balancer
- Autoscalling Group
- Security Groups
- Amazon Machine Image