AWS, EC2, RDS, Configuring the DataBase on RDS, WordPress.

AWS, EC2, RDS, Configuring the DataBase on RDS, WordPress.

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

What is RDS in AWS?

Amazon Relational Database Service (Amazon RDS) is a web service that makes it easier to set up, operate, and scale a relational database in the AWS Cloud. It provides cost-efficient, resizable capacity for an industry-standard relational database and manages common database administration tasks.

Step 1: Creating 2 security groups one for the 1 for the EC2 and one for the RDS

Security Group 1: WPEC2 with ssh and HTTP allowed.

No alt text provided for this image

Security Group 2: RDS

As the data is very important we only want the ec2 instance to connect to our database server. Therefore, we add a custom SG which we created up WPEC2 for the RDS server

No alt text provided for this image

Step 2: Launch an EC2 instance

1. Here, I am using an Amazon Linux

No alt text provided for this image

2. Free tire: t2micro

No alt text provided for this image

3. Configure Instance

In Advance details,

No alt text provided for this image

The above block of code will install PHP, httpd, some extras, and also install WordPress in the root directory of the webserver. This block of code will help us to spend less time on EC2.

4. Configure security Groups ADD WPEC2 which we created up there.

No alt text provided for this image

Now, we can launch the EC2 instance successfully

No alt text provided for this image

httpd service running successfully.

Step 3: Launch an RDS.

We are using a MySQL Database.

No alt text provided for this image

DB instance size

No alt text provided for this image

Credentials:

No alt text provided for this image

Storage:

No alt text provided for this image

Do not give the public access to the RDS instance, So only the EC2 can connect the DataBase server.

No alt text provided for this image

Choose the existing security group which we created for RDS in the First step

No alt text provided for this image

In Additional Configuration,

Create a database

No alt text provided for this image

BACKUP

No alt text provided for this image

Keep the maintenance as it was and launch the RDS database

No alt text provided for this image

Successfully launched the database

No alt text provided for this image

Now both things are ready the EC2 with httpd service started and the RDS instance for DataBase.

Step 4: Configure the WordPress website and database server.

On the EC2 public IP

No alt text provided for this image

Restart the httpd service in the EC2


service httpd restart        
No alt text provided for this image

Adding the database information and Endpoint.

No alt text provided for this image

You can get the endpoint in the connectivity and security menu of RDS.

No alt text provided for this image

The below error arises because the apache user has no power to create a file and write in it.

  1. So we have to manually create a file and copy this contend

Note: Do not try to copy the wp-config-sample.php because it does not contain the secret keys

No alt text provided for this image
No alt text provided for this image

And copy the above contained in this file wp-config.php and Run the installation.

Note: If any error comes after running the installation restart the httpd service and give the 755 permission to the wp-config.php file and also make apache the owner of wp-config.php i.e chown -R apache: apache wp-config.php

No alt text provided for this image

Successfully installed WordPress and created the user

LOGIN

No alt text provided for this image
No alt text provided for this image

we have done it successfully!!

Thank you🙌

To view or add a comment, sign in

More articles by Faizan Shaikh

Explore content categories