Deploying WordPress using Amazon RDS
Task Description
- Create an AWS EC2 instance.
- Configure the instance with Apache Webserver.
- Download PHP application named “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 into the task:
Step 1 : Create the MySQL RDS.
- Services -> Database -> RDS.
- Click on Create database.
- Select MySQL
- Select latest version of MySQL. Next select free tier so that we don’t get charged.
- Name your database and set the user name and password for the database.
- Leave rest of settings as default and in the Public access we need to select yes or else we won’t be able to connect to WordPress.
- We have to choose the security group if we have already created any, otherwise we can create a new one.
- Now, click on create database.
- It will take few minutes to launch the database. So, wait for some time.
Step 2: Launch EC2 instance and configure WordPress.
- Create EC2 instance either by GUI or CLI
- Click on connect, to connect to the EC2 instance.
- 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 -y
: to install apache webserver
$ yum install mysql -y
: to install 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
- Enable the httpd service
- Enter your public IP of EC2 instance on browser followed by the wordpress folder “publicIP/worpress”.
Step 3 : Check the RDS MySQL database connectivity.
- Copy the database endpoint.
- Run the below command to connect your database. Enter the correct endpoint, username and password in this command.
- We can run MySQL commands to check database and tables.
- We can open the WordPress server in the browser now.
- 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.
- Restart httpd and mysql service.
- Now again go to the browser and refresh the page and enter the details and click on install wordpress.
- Login to WordPress site.
- Click on “view your site”.
- Now click on Edit to edit your wordpress site accordingly.
- 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.
- If we print the wp_posts, we’ll to able to see the content.
- If we print the data of wp_comments, we’ll see the comments.