Integrate WordPress with AWS RDS

In this article, we are going to deploy “WordPress” which is a free and open-source content management system written in PHP on top of AWS EC2 Instance.

As WordPress is a frontend application it requires a database to store its data. So we will use MySQL Database Server as a backend database for WordPress and MySQL will be set up using Amazon RDS.

Finally, we will provide the endpoint of MySQL to WordPress for connectivity.

Task To DO:

Create an AWS EC2 instance.

Configure the instance with Apache Webserver.

Download php application name “WordPress”.

WordPress stores data at the backend in MySQL Database Server. Therefore, you need to set up a MySQL server using AWS RDS service using Free Tier.

Provide the endpoint/connection string to the WordPress application to make it work.

“Technology is just a tool. In terms of getting the kids working together and motivating them, the teacher is most important.”~ by Bill Gates

So let’s start walking through this Task & Complete it!

Step 1: Create an AWS EC2 instance

🔅 We need to launch an EC2 Instance on AWS which we will use to configure Apache Webserver and run WordPress.

Let’s quickly launch the instance :

Finally, launch the instance after attaching the Key pair.

Now you can use Public IP address any Key to connect this Instance. You can use Putty(Recommended) or CLI Browser provided by Amazon to Connect Instance.

But here we use CLI Browser:

Step 2: Configure the Instance with Apache Webserver

Here we are going to configure the Apache Web Server in Amazon Linux 2 Instance.

To run WordPress, we need to run a web server on our EC2 instance. The open-source Apache web server is the most popular web server used with WordPress.

Let’s quickly Configure it:

🌀 Install Apache Web Server

# sudo su -

# yum install httpd -y

Then we are Starting Web server and Enable it Permanently.

# systemctl start httpd

# systemctl enable httpd

Step 3: Download PHP application name “WordPress” and Configure IT

WordPress is a php Application, let’s install php 7.2.

With Amazon Linux 2, you can use the Extras Library to install application and software updates on your instances.

Let’s quickly Configure it:

# amazon-linux-extras install -y php7.2

After that download the WordPress file.

# wget http://wordpress.org/latest.tar.gz

After download, the “TAR” file “UNTAR” it.

# tar -xvzf latest.tar.gz

Next you see “wordpress” name dir come up. So now you can copy all Content inside “wordpress” folder to Document Root “/var/www/html”.

cp -rf wordpress/* /var/www/html

Note: Make Sure where you download your “tar” file and where you “Untar” it.

Step 4: Set up a MySQL server using AWS RDS service using Free Tier

Let’s now launch a MySql database using Amazon RDS.

Choose “Standard Create” -> Select “MySQL”

Select Version “MySQL 8.0.20” -> Select “Free tier”

Give DB Instance name -> Provide Username & Password

Here this DB instance has No Connectivity to the Internet.

Now after Launching this DB Instance “mydb” named Database will be created inside this DB server.

Here is the “Endpoint” of this DB Instance using this WordPress Application will connect to it.

Here this DB Instance is not Having any Internet Access, It can Only connect to Subnets inside VPC. No Public Accessibility

Step 5: Provide the Endpoint/Connection string to the WordPress Application

Go to the EC2 Instances page and find your instance. In the Description below, find the Public DNS (IPv4) of your instance.

Enter this IP Address into your web browser. Next Step -> “let’s go”.

Provide Following Information:

Database Name: Provide the Name of the Database created at the time of launching DB.

Username: The username you gave while launching DB Instance.

Password: Provide Password.

Database Host: Provide the ENDPOINT which you get from “WordPress-db-1”.

After Submit these

Copy paste these Code files “wp-config.php”.

Put copied code in “/var/www/html/wp-config.php” at EC2 Instance where WordPress is deployed.

Note: “Please Use Putty while copy and paste these codes to ‘wp-config.php’. Because if using CLI browser it will provide extra spaces unnecessarily and it will not work and give an error!”

# vim wp-config.php

Now our WordPress is running on the AWS using AWS RDS as a service and in the backend it is using MySQL.

Provide the Following Details and Install WordPress!

After Login with the credentials and log in to WordPress

As WordPress is a frontend application it requires a database to store its data. So we will use MySQL Database Server as a backend database for WordPress and MySQL will be set up using Amazon RDS.

Finally, we will provide the endpoint of MySQL to WordPress for connectivity.

Successfully done! We have Login into WordPress and we can continue to write Blogs etc., All your Data will Be stored in RDS MySQL DB.

I Hope from these Article you get Idea to Integrate RDS MySQL with WordPress!

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

WHY YOU ARE FAILING AS A WEB DEVELOPER

A group of men and women happily looking at a laptop

Recommending & using the same VSCode extensions within a workspace

VSCode

CS371p Spring 2022 Relena Lai

How Scrum kept me sane during a pandemic

Configure _Hadoop _Cluster _using _Ansible _Playbook_

Describing Experimental/Simulation Setup

Mobile Application Development

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Srasthy Chaudhary

Srasthy Chaudhary

More from Medium

Cracking a Weak Password

Backup & Archive with AWS

Containers on AWS

Get your own VPN with no logs -OpenVPN+Linode