Project: Deploy WordPress with Amazon RDS
Today(Day:45), we will dive into the process of deploying WordPress with Amazon RDS, a managed relational database service. Let's get started on this journey!
Task: Deploying WordPress with Amazon RDS
Step 1: Create an EC2 Instance
Begin by creating a new EC2 instance in the AWS Management Console. Here are the steps to follow:
- Launch the EC2 instance and configure the necessary settings.

- Create a new security group and add MYSQL/Aurora to the inbound rule.

- Launch the instance.
Step 2: Create an RDS Database
Next, we will create an RDS database for WordPress. Follow these steps:
- Create RDS database and Choose the MySQL database engine and select the Free tier option.


- Provide a name for the DB instance and set a master username and password.

- In the connectivity options, choose to connect to an EC2 compute resource.

- Select the VPC security group you created earlier.

- In the additional configuration, provide a name for the database.

Step 3: Create an IAM Role for EC2
To allow EC2 to access RDS, we need to create a new IAM role. Here's how:
- Create a new IAM role and add the permissions for AmazonRDSFullAccess.


- Give the role a name.

Step 4: Assign the IAM Role to the EC2 Instance
Assign the IAM role you created in Step 3 to the EC2 instance. Here's how:
Go to the EC2 dashboard in the AWS Management Console
Click on the EC2 instance and go to "Actions" -> "Security" -> "Modify IAM role."

- Select the created IAM role.

Step 5: Connect to the RDS Database and Install MySQL
SSH into your EC2 instance and install the MySQL client:
sudo apt install mysql-client-core-8.0

Connect to your RDS database using the following command:
mysql -h wordpress-db.cttltix4r4qx.us-east-2.rds.amazonaws.com -P 3306 -u admin -p
# mysql -h [RDS Endpoint] -P 3306 -u [admin] -p
#(Note: Replace [RDS Endpoint] with your RDS database's endpoint and [admin] with your username.)

Once connected, create the WordPress database and user:
CREATE DATABASE wordpress;
CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-99';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
FLUSH PRIVILEGES;
exit

Step 6: Install Apache and Configure WordPress
Install Apache on your EC2 instance:
sudo apt-get install apache2

Restart Apache:

Check your IP address in a web browser, and you should see the Apache default page.

To install WordPress, run the following commands:
wget https://wordpress.org/latest.tar.gz

tar -xzf latest.tar.gz
cd wordpress/
sudo cp wp-config-sample.php wp-config.php
sudo vim wp-config.php

Update the wp-config.php file with the correct DB_HOST (your RDS database endpoint).

Install PHP and MySQL module:
sudo apt install php libapache2-mod-php php-mysql -y

Copy the WordPress folder to /var/www/html:

Restart Apache again:

Open YOUR-IP/wp-admin in a web browser.

Congratulations! You have successfully deployed WordPress with Amazon RDS. Enjoy exploring the vast possibilities with this powerful combination.
If you have any queries or suggestions, please leave a comment below.
See you another day with another exciting challenge!



