Launch WordPress on AWS & Connect to MySQL RDS Database

Niharika Dhanik
3 min readJan 12, 2022

--

Here, we are going to integrate AWS with WordPress and also get to learn more about Amazon RDS Service.

Steps to complete the task are —

  • Create an AWS EC2 instance
  • Configure the instance with Apache Webserver
  • Download PHP application name “WordPress”
  • Setup a MySQL server using AWS RDS service
  • Provide the endpoint/connection string to the WordPress application

The Execution —

Step 1 — Create an AWS EC2 instance

(for creating EC2 instance refer → https://niharicka.medium.com/key-pair-security-group-volume-creation-on-aws-using-cli-c7e28d3eceab)

Step 2 —Configure the instance with Apache Webserver
(for setting webserver refer step 1 of → https://niharicka.medium.com/high-availability-architecture-with-aws-cli-551c708890ae)

Step 3 — Download PHP application name “WordPress”
Sub Steps involve : installing pre-requisites for hosting the WordPress Website

# PRE-REQUISITES
[root@ip-172-16-97-255 ~]# yum install php
[root@ip-172-16-97-255 ~]# yum install php-mysqlnd[root@ip-172-16-97-255 ~]# yum install php-fpm[root@ip-172-16-97-255 ~]# yum install mariadb-server
# DOWNLOAD THE REQUIRED PHP APPLICATION
[root@ip-172-16-97-255 ~]# curl https://wordpress.org/latest.tar.gz --output wordpress.tar.gz
# UNZIP FILE AND COPY IT TO DEFAULT APACHE WEBSERVER FOLDER
[root@ip-172-16-97-255 ~]# tar xf wordpress.tar.gz
[root@ip-172-16-97-255 ~]# cp -r wordpress /var/www/html
# PROVIDING SUDO ACCESS TO THE APACHE USER
[root@ip-172-16-97-255 ~]# chown -R apache:apache /var/www/html/wordpress/
[root@ip-172-16-97-255 ~]# chcon -t httpd_sys_rw_content_t /var/www/html/wordpress/ -R

Step 4 — Setup MySQL server using AWS RDS Service
Sub Steps involve : create MYSQL database on RDS, launch the Database

Setup AWS RDS Console :

  • Inside the AWS RDS Console, create a database with
ENGINE OPTIONS :: MySQL
EDITION :: MYSQL Community
VERSION :: mysql 5.8.1
DB INSTANCE IDENTIFIER :: mydb1
MASTER USERNAME :: niharika
MASTER PASSWORD :: ******
DATABASE INSTANCE SIZE :: Burstable classes [includes t classes]
STORAGE TYPE :: General Purpose (SSD)
ALLOCATED STORAGE :: 25 Gib
STORAGE AUTOSCALING :: ENABLE STORAGE AUTOSCALING (check the box)
MAXIMUM STORAGE THRESHOLD :: 50 Gib
VPC :: Default
SUBNET GROUP :: Default
PUBLIC ACCESS :: NO
VPC SECURITY GROUP :: choose existing
DATABASE PORT :: 3306
  • Launch the database
[root@ip-172-16-97-255 ~]# mysql -h mydb1.col64zxct6js.ap-south-1.rds.amazonaws.com -u niharika -p /* enter the password on prompt and its done*/ 

Step 5 — Provide the endpoint/connection string to the WordPress application

Enter the following details and proceed
Enter the credentials and login

And its done.

Thank You!

--

--