Integration Of WordPress with Amazon RDS on AWS
Tags: aws, wordpress, database, amazonrds
Published: 2021-03-28 15:41:37

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ku15rpd92wepgv11ye2t.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gycj87yczy07uykegnnt.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kh03pl1zzazynmv96469.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ez49ds7qtxipawhi7hke.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mt6hledo0e0xst7bo2vn.png)
The below mentioned command is also important and it will install some dependencies and softwares

amazon-linux-extras install php7.3
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ce1o7nscpz8h5dg5iy9w.png)
#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   
Also we have to extract it.

    tar xf wordpress.tar.gz
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jknbf7hbk0trp8idseam.png)
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 

We will use

    cp -r wordpress /var/www/html
After this Start the Apache webserver services:

    systemctl start httpd
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u88u04410i7yiwhmyeu6.png)

#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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ikze5589iybxclmmlgz.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z61tu4f4c60pv83ugxco.png)
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

7) In the DB instance size section:  
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x8ojd3druzj141xqun4g.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9k14dat7nv1zzs8oqtj.png)
9) Now just create the database
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gw2zhqqhoehcyzms0oyc.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/905uok1drdsygj9sy3md.png)
You can also access this database from the terminal.
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ktue9tffy53oglwi5eln.png)
Lastly, Provide the endpoint/connection string to the WordPress application to make it work.
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q9coffpgsdmitfha5o4k.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cugdto09t14vx5ie5xht.png)
![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knmowznchb071laur69l.png)
#Voila!!! We did it.

That’s It, Thanks for Reading !! 📃

Keep Sharing, Keep Hustling🎯🎯🎯