AWS RDS and WordPress Integration

Nirali Arora
7 min readMay 28, 2021

Task Description:

🔅 Create an AWS EC2 instance
🔅 Configure the instance with Apache Webserver.
🔅 Download php application name “WordPress”.
🔅 As wordpress stores data at the backend in MySQL
Database server. Therefore, you need to setup a
MySQL server using AWS RDS service using Free Tier.
🔅 Provide the endpoint/connection string to the
WordPress application to make it work.

What is Amazon RDS?

Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while automating time-consuming administration tasks such as hardware provisioning, database setup, patching and backups. It frees you to focus on your applications so you can give them the fast performance, high availability, security and compatibility they need.

Amazon RDS is available on several database instance types — optimized for memory, performance or I/O — and provides you with six familiar database engines to choose from, including Amazon Aurora, PostgreSQL, MySQL, MariaDB, Oracle Database, and SQL Server. You can use the AWS Database Migration Service to easily migrate or replicate your existing databases to Amazon RDS.

What is WordPress?

WordPress is a free and open-source content management system written in PHP and paired with a MySQL or MariaDB database. Features include a plugin architecture and a template system, referred to within WordPress as Themes. WordPress was originally created as a blog-publishing system but has evolved to support other web content types including more traditional mailing lists and forums, media galleries, membership sites, learning management systems and online stores. WordPress is used by more than 40.5% of the top 10 million websites as of March 2021, WordPress is one of the most popular content management system solutions in use. WordPress has also been used for other application domains, such as pervasive display systems.

What is MySQL?

MySQL is an open-source relational database management system (RDBMS). Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language. A relational database organizes data into one or more data tables in which data types may be related to each other; these relations help structure the data. SQL is a language programmers use to create, modify and extract data from the relational database, as well as control user access to the database. In addition to relational databases and SQL, an RDBMS like MySQL works with an operating system to implement a relational database in a computer’s storage system, manages users, allows for network access and facilitates testing database integrity and creation of backups.

Let’s jump to the task :)

Firstly we are creating a database using the AWS RDS service

All services → Database → RDS

Now select Create database

Choose MySQL

I am using free tier here

Create username and password for the database

Give a name to database

Allowing public access so that we can connect our database from EC2 instance

Keeping rest of the settings same click on create database

It takes time to be available so by the mean time we can configure EC2 instance.

Our database is created.

Click on Launch instances option mentioned towards the top right

I m choosing Amazon Linux 2 AMI

Giving a name to our instance

Allowing all traffic

Now we have to select a key pair.

I already have one, you can create a new key pair.

our instance has been launched successfully

Now connect to the instance by selecting the instance and click on connect

  • Run the following command:

$ sudo su - : to become root user so that you can run all the command with root privilege.

  • To setup the WordPress we need to install some software.

$ yum install httpd mysql -y : to install apache webserver and mysql

  • Run the following command:

$ amazon-linux-extras install php7.4 : to get command to install PHP

  • Now go to the official site of WordPress https://wordpress.org/download/ and copy the download link.
  • Go to the “cd /var/www/html/” folder.
  • Run the command to download the wordpress software.

$ wget https://wordpress.org/latest.tar.gz

  • Use the command to unzip the Wordpress software.

$ tar -xf latest.tar.gz

  • Run the command to start httpd service.

$ systemctl start httpd

  • Run the command to enable httpd service.

$ systemctl enable httpd

  • We can also check the httpd service inside wordpress folder.
  • Copy the public IP address of EC2 instance so that we can login wordpress from browser.
  • Enter your public IP of EC2 instance on browser followed by the wordpress folder “publicIP/worpress”.
  • Fill the login details of Database
  • Copy the database endpoint and paste in the database host option above
  • As soon as we hit we get the following error which depicts that our work of configuring is not done yet.
  • Login to and go to the wordpress folder and copy wp-config-sample.php to wp-config.php
  • now open this wp-config.php file and enter the database name, user , password and endpoint of RDS mysql database.
  • Now again go to the browser and refresh the page and enter the details and click on submit.
  • Fill the details and click on install WordPress.
  • Login to wordpress using credentials.
  • Wordpress site has been started.
  • Now again login to your Mysql database to verify if the data is being stored or not.
  • Go to the WordPress database (sqldb in my case) and see the tables.

We can see that MySQL (RDS) and WordPress are working good together.

That’s all for this task.

Open for queries and suggestions.

Linkedin: https://www.linkedin.com/in/nirali-arora/

KEEP LEARNING !! KEEP SHARING!!

Thank you :)

--

--

Nirali Arora

ARTH Learner | AWS | Devops | Docker | Ansible | Kubernetes | MLOPS | Linux | Python | Python flask | AI | ML | DL | CV | MongoDB | Hadoop | GIT | GitHub