DEV Community

Cover image for Integration Of WordPress with Amazon RDS on AWS
Piyush Bagani
Piyush Bagani

Posted on

Integration Of WordPress with Amazon RDS on AWS

Hello Readers😊,

In this blog, I am going to integrate the WordPress with Amazon RDS. So without any further delay Let’s Get started..

What Is AWS?

alt text
Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 175 fully featured services from data centers globally. Millions of customers — including the fastest-growing startups, largest enterprises, and leading government agencies — are using AWS to lower costs, become more agile, and innovate faster.

What is AWS-RDS?

alt text
Amazon RDS is the Relational Database Service offered as a web service by Amazon. It makes it easy to set-up and operate a relational database in the cloud. It provides a very cost-effective way to use industry’s leading RDBMS software as a managed service. Because of this web service from amazon AWS, You do not have to buy any server or install any database software in it. You just have subscribe to the AWS RDS web service and start using the RDBMS features after some initial configuration involving memory and CPU capacity allocation etc.

What is WordPress?

alt text
WordPress is an open source Content Management System (CMS), which allows the users to build dynamic websites and blog. WordPress is the most popular blogging system on the web and allows updating, customizing and managing the website from its back-end CMS and components.WordPress is an excellent website platform for a variety of websites. From blogging to e-commerce to business and portfolio websites, WordPress is a versatile CMS. Designed with usability and flexibility in mind, WordPress is a great solution for both large and small websites.

Prerequisites:

For this, there are some Prerequisite

An account on AWS so that we can use its resources.
Basic knowledge of how to launch EC2 instances on AWS cloud.

Let’s Start Now

Launch an EC2 instance For Deploying WordPress

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers. Amazon EC2’s simple web service interface allows you to obtain and configure capacity with minimal friction. It provides you with complete control of your computing resources and lets you run on Amazon’s proven computing environment.
For launching EC2 instance you can follow below mentioned link:
https://docs.aws.amazon.com/quickstarts/latest/vmlaunch/step-1-launch-instance.html
Here I launched the Amazon Linux 2 instance using AWS Management Console. You can also use AWS CLIv2 which is the Command Line Version.

To know more about AWS CLIv2 you can refer to my another blog mentioned below.
https://dev.to/piyushbagani15/getting-started-with-aws-cliv2-135n
After Launching the instance, just connect To the Instance

To connect from the Amazon EC2 console

1) Open the Amazon EC2 console.
2) In the left navigation pane, choose Instances and select the instance to which to connect.
3) Choose Connect.
After this we have to install the some important softwares

The following command will install httpd software useful for configuring instance as webserver.
alt text
alt text
The below mentioned command is also important and it will install some dependencies and softwares

amazon-linux-extras install php7.3
alt text

Download WordPress code from the Internet and Extract it

The following command will download the WordPress from Internet.

 curl https://wordpress.org/latest.tar.gz --output wordpress.tar.gz   
Enter fullscreen mode Exit fullscreen mode

Also we have to extract it.

tar xf wordpress.tar.gz
Enter fullscreen mode Exit fullscreen mode

Also just for information:

The Linux ‘tar’ stands for tape archive, is used to create Archive and extract the Archive files. tar command in Linux is one of the important command which provides archiving functionality in Linux.

Syntax:

tar [options] [archive-file] [file or directory to be archived.
Options:
-c : Creates Archive
-x : Extract the archive
-f : creates archive with given filename
-t : displays or lists files in archived file
-u : archives and adds to an existing archive file
-v : Displays Verbose Information

alt text
Now, Copy the extracted WordPress directory into the /var/www/html directory:

Here’s how to copy a directory in Linux:

cp -r source_directory destination_directory 
Enter fullscreen mode Exit fullscreen mode

We will use

cp -r wordpress /var/www/html
Enter fullscreen mode Exit fullscreen mode

After this Start the Apache webserver services:

systemctl start httpd
Enter fullscreen mode Exit fullscreen mode

alt text

Create RDS database For WordPress

To create a MySQL DB instance

1)Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.
2) In the upper-right corner of the AWS Management Console, choose the AWS Region where you want to create the DB instance.
3) In the navigation pane, choose Databases.
4) Choose Create database.
5) On the Create database page, shown following, make sure that the Standard Create option is chosen, and then choose MySQL.
alt text
alt text
Here I am using free tier account so In the Templates section, choose the Free tier.

6) In the Settings section, set these values:

DB instance identifier — Mydb
Master username — Give username
Auto-generate a password — Disable the option
Master password — Choose a password.
Confirm password — Retype the password
Enter fullscreen mode Exit fullscreen mode

7) In the DB instance size section:

alt text
In the Storage and Availability & durability section, Use default values.

8) In the Connectivity section,Use default values.

If you want to change, You can…
alt text
9) Now just create the database
alt text
10) Wait for the Status of your new DB instance to show as Available. After some minutes you will see that the database is created.
alt text
You can also access this database from the terminal.
alt text
Lastly, Provide the endpoint/connection string to the WordPress application to make it work.
alt text
alt text
alt text

Voila!!! We did it.

That’s It, Thanks for Reading !! 📃

Keep Sharing, Keep Hustling🎯🎯🎯

Top comments (0)