Command Palette
Search for a command to run...
Comments
Join the discussionNo comments yet. Be the first to comment.
Search for a command to run...
No comments yet. Be the first to comment.

First, we are going to follow the architecture diagram from above.



Internet Gateway is used to communicate all outside internet traffic to our VPC.

Attach the Internet Gateway to the Dev VPC that you created. You can attach and detach the VPC from action tab.

Create a subnet and make sure you select your VPC with correct zone and IPv4 address. You will find those details on architecture photo



Edit routes:

Attach the Dev Internet Gateway with IP 0.0.0.0/0 which means from everywhere:

Edit subnet associations:

Attach your public subnets to it:

Nate gateway is being used to communicate traffic of our private subnet to Internet gateway.

As you can see in above diagram, 2 Nate gateways are created in public subnets and it is being attached to new private route table that has private subnets attached to it respectively.


Go to Private Route Table AZ1 and edit routes:

Allow all Internet traffic to Nate Gateway AZ1

Add both Private App Subnet AZ1 and Private Data Subnet AZ2 in the Route table

Follow same steps for Private Route table AZ2 and add Nate Gateway AZ2 and Private App Subnet AZ2 and Private Data Subnet AZ2

ALB Security Group

SSH Security Group

Webserver Security Group

Database Security Group

EFS Security Group
Once you create EFS Security Group, click on Edit Inbound Rules:
Add EFS Security Group

Go to Amazon RDS
First, we will create a subnet group to group together our private database subnets in us-east-1a and us-east-1b

Now, create a new RDS DB using following details. Make sure you'll create a RDS in our DEV VPC

Go to EFS


#1. create the html directory and mount the efs to it
sudo su
yum update -y
mkdir -p /var/www/html
#Go to EFS system and find DNS nameme
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport FILE_SYSTEM_NAME:/ /var/www/html
#2. install apache
sudo yum install -y httpd httpd-tools mod_ssl
sudo systemctl enable httpd
sudo systemctl start httpd
#3. install php 7.4
sudo amazon-linux-extras enable php7.4
sudo yum clean metadata
sudo yum install php php-common php-pear -y
sudo yum install php-{cgi,curl,mbstring,gd,mysqlnd,gettext,json,xml,fpm,intl,zip} -y
#4. install mysql5.7
sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
sudo yum install mysql-community-server -y
sudo systemctl enable mysqld
sudo systemctl start mysqld
#5. set permissions
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 {} \;
sudo find /var/www -type f -exec sudo chmod 0664 {} \;
chown apache:apache -R /var/www/html
#6. download wordpress files
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
cp -r wordpress/* /var/www/html/
#7. create the wp-config.php file
cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
#8. edit the wp-config.php file
nano /var/www/html/wp-config.php
#you need to edit the config file to attach RDS DB and SSL certificate
/* SSL Settings */
define('FORCE_SSL_ADMIN', true);
// Get true SSL status from AWS load balancer
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = '1';
}
#9. restart the webserver
service httpd restart
