Integrating WordPress with AWS’s RDS and EC-2

mayank sharma
5 min readJan 24, 2021

Our aim is to launch WordPress on AWS. We will set up our software on one of the EC-2 instances of AWS using Amazon Linux 2 as our operating system. As we know WordPress needs a relational database for storing data for fulfilling that purpose we will use AWS RDS. Without investing much time we will directly see the practical.

Here we go…

Step-1

🔅 Launch an AWS EC2 instance…

We will choose Amazon Linux 2 as our base operating system and t2.micro instance type which comes under AWS free tier.

Since we are going to connect to our system remotely for configuring it and then after we will connect to WordPress using a web browser so we have to allow SSH and HTTP in our security group’s inbound rules.

Rest of the things we will use the default properties given by the AWS.

Step-2

🔅 Configure the instance with Apache Webserver.

Since we will set up WordPress on the top of the Apache WebServer (httpd) we have to install it and then configure it.

For achieving the root powers we will run the command:-

# sudo -su root

For installing httpd:-

# yum install httpd -y

Step-3

🔅 Download PHP application name “WordPress”.

Since WordPress works on PHP we will first install PHP.

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

Now we will download WordPress compressed files from the website and then decompress them.

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

# tar -xzf latest.tar.gz

Since httpd stores webpages in /var/www/html by default we will move the folder there.

# mv wordpress /var/www/html

Since we have configured our webserver successfully so now we will start and enable it permanently.

# systemctl enable httpd — now

Step-4

🔅 Creating a database using AWS’s DBaaS RDS.

We will go to the RDS service of AWS and create a new database.

Follow the below steps:-

Since we will use MySQL we will choose it.
We are just learning so we will go for the free tier.
e

Now our database has been successfully created.

We will go to the databases in the RDS dashboard and copy the endpoint of our database so we can use it further.

This is the endpoint of our RDS database using which we can connect with it.

Step-5

🔅 WordPress stores data at the backend in the MySQL Database Server. Therefore, we need to set up a MySQL server.

First, we will install MySQL on our system.

# yum install mysql -y

Now we will connect to our RDS database.

# mysql -h database-1.cc667bj38azc.ap-south-1.rds.amazonaws.com -u admin -p

Now we will create a database for WordPress.

MySQL > create database wordpress_db

Step-6

🔅 Now we will connect to WordPress and provide the endpoint/connection string to the WordPress application to make it work.

We will give the following URL to our web browser and follow the steps.

http://13.235.76.196/wordpress/wp-admin/setup-config.php

We will provide the required details and the endpoint of RDS.

We will copy the data above and create a file manually and paste the data there and then click on Run the Installation.

# cat > wp-config.php

That is it our setup is ready now we will sign in and then log in to WordPress and use it.

This is the WordPress dashboard and now we can use it as per our needs.

We can check in our MySQL server and we will see that there are some tables that are automatically created by WordPress. These are the tables in which WordPress stores its data.

Thank You…

--

--