Relational Database Service (RDS) in AWS &Deploy Wordpress website on AWS

Relational Database Service (RDS) in AWS &Deploy Wordpress website on AWS

Today we will learn more about relational database services (RDS) in AWS and learn how to deploy Wordpress website on AWS.

What is RDS:

Amazon Relational Database Service (Amazon RDS) is a collection of managed services that makes it simple to set up, operate, and scale databases in the cloud

Among the supported database engines, MySQL stands out for its open-source reliability and performance.

WordPress:

WordPress has become the go-to choice for content management systems, powering over 30% of all websites on the internet. While commonly associated with blogs, its versatility extends to running e-commerce sites, message boards, and various other applications.

Lets setting up a WordPress blog site on Amazon Web Services (AWS), using an Amazon EC2 instance for hosting and an Amazon RDS for MySQL database to store your WordPress data.

Task-01

  • Create a Free tier RDS instance of MySQL

  • Create an EC2 instance

  • Create an IAM role with RDS access

  • Assign the role to EC2 so that your EC2 Instance can connect with RDS

  • Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.

Solution

Step 1 :Navigate RDS service in AWS console and select create new database.

Select image as MySQL

Hit create database button and we could see database in console

Step 2 : Create an IAM Role with RDS Access

Add permission for RDS.

Hit Create role button.

Role got created and we could access in portal now.

Step 3: Lets create EC2 instance and attach role to to instance

Hit update IAM role button.

Step 4: Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.

We need to modify IAM role for EC2 instance first.

Update IAM role.

Now we also need to link our EC2 instance with database so both will stay in one PVC.

choose our instance from drop down and click on continue.

In database console we could se our instance as connected compute resources.

To connect RDS we need mysql client which we can install with below command on ec2.

To connect to database we will execute below command

mysql -u <username> -h <rds-database-endpoint> -P <port-no> -p

Now we are able to connect database and execute SQL.

Over 30% of all websites on the internet use WordPress as their content management system (CMS). It is most often used to run blogs, but it can also be used to run e-commerce sites, message boards, and many other popular things. This guide will show you how to set up a WordPress blog site.

Task-02

  • As WordPress requires a MySQL database to store its data ,create an RDS as you did in Day 44

To configure this WordPress site, you will create the following resources in AWS:

  • An Amazon EC2 instance to install and host the WordPress application.

  • An Amazon RDS for MySQL database to store your WordPress data.

  • Setup the server and post your new Wordpress app.

solution

Step 1: We have already created mysql database in task 1. Lets create a database wordpress and user for your wordpressadmin, and then grant access to the WordPress database to the user.

Step 2: Our EC2 instance, must operate as web server in order to run WordPress. Will install Apache on our EC2 instance:

to verify Apache 2 installation we can use public-ip of instance and browser and could see apache2 home page like below.

Step 3: Set up the server and post our new WordPress app using below command.

Download wordpress extarct from wget https://wordpress.org/latest.tar.gz and unzip in ec2 instance.

Open the wp-config.php file and Modify the following lines in the database configuration

I have set the following parameters in our configuration:

  • DB_NAME: Refers to your RDS database name.

  • DB_USER: Denotes the username created within the previous database steps.

  • DB_PASSWORD: Represents the password associated with the previously created user.

  • DB_HOST: Indicates the database's hostname, essentially your database endpoint.

For the Authentication Unique Keys and Salts configuration section, replace all content within that area with the following text: Ensure the creation of the specific details using https://api.wordpress.org/secret-key/1.1/salt

Step 4: Ensure you've replaced the placeholder text with your generated content. Begin by installing the necessary dependencies for the WordPress application. Execute the following command in your terminal:

sudo apt install php libapache2-mod-php php-mysql -y

Next, transfer your WordPress application files to the /var/www/html directory designated for Apache:

sudo cp -r wordpress/* /var/www/html/

Lastly, restart the Apache web server. To view the WordPress welcome page, navigate to "ec2-public-ip/wp-admin/".

Hurrey...!!! The WordPress blog has been set up successfully, with the MySQL database linked to the app.

I trust this article has been valuable and provided an excellent hands-on experience!

Thank you for taking the time to read it.

Thanks,

Kishor Chavan