# 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:

1. Launch the EC2 instance and configure the necessary settings.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709462091/027dbb54-70f7-4b65-bfba-43c7f46b7969.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709508169/bc3e3f9c-2981-457a-bd49-9fb834756721.png align="center")

1. Launch the instance.
    

**Step 2: Create an RDS Database**

Next, we will create an RDS database for WordPress. Follow these steps:

1. Create RDS database and Choose the MySQL database engine and select the Free tier option.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709579452/c66b0e5a-f4f2-44c3-9a9e-72c10e3af6e8.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709653535/3b13eb56-261d-464b-a1ae-f1bd62b9ff3e.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709686720/6457e48f-97f4-4e2e-bbd8-73afb374fe80.png align="center")

1. In the connectivity options, choose to <mark>connect to an EC2 compute resource.</mark>
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709749534/1d254b5e-6da9-4e8c-8c09-fb7c4555f077.png align="center")

1. Select the VPC security group you created earlier.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709836440/9128e29a-3c28-4960-ab95-07986dfe550e.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709904332/4a3b958e-56bc-44de-85de-850ca110752c.png align="center")

**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:

1. Create a new IAM role and add the permissions for AmazonRDSFullAccess.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686709948576/3611b342-eebf-47db-871b-b01e945bf890.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710000476/58fac137-f0d2-428a-8784-cb6cce4440b4.png align="center")

1. Give the role a name.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710039774/df93605a-09d5-4b78-856c-f6be4a76568b.png align="center")

**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:

1. Go to the EC2 dashboard in the AWS Management Console
    
2. Click on the EC2 instance and go to "Actions" -&gt; "Security" -&gt; "Modify IAM role."
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710069261/04d38faa-f6d2-4d18-ab62-5d8459615529.png align="center")

1. Select the created IAM role.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710147055/9a4dd053-5f89-49e3-aa87-36611a72854e.png align="center")

**Step 5: Connect to the RDS Database and Install MySQL**

SSH into your EC2 instance and install the MySQL client:

```bash
sudo apt install mysql-client-core-8.0
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710178698/b05ae312-67ea-4f3d-88f3-3536eea44ee5.png align="center")

Connect to your RDS database using the following command:

```bash
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.)
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710240939/dd9a5acd-23e3-4275-a117-81cf85dfaa79.png align="center")

Once connected, create the WordPress database and user:

```bash
CREATE DATABASE wordpress;
CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-99';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
FLUSH PRIVILEGES;
exit
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710385883/7d66f8e5-0193-426b-bf06-86ad2b43fd10.png align="center")

**Step 6: Install Apache and Configure WordPress**

Install Apache on your EC2 instance:

```bash
sudo apt-get install apache2
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710508489/71c0f39f-c2f7-44ba-aac9-4e486e7935b6.png align="center")

Restart Apache:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710558291/ddf85d3a-a17c-4a31-8d71-32a48f226499.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710580950/cd2fbaf8-547f-4244-b911-d3c0cd1ae57e.png align="center")

To install WordPress, run the following commands:

```bash
wget https://wordpress.org/latest.tar.gz
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710639238/782ca1f7-57aa-4af1-b5fd-f4f47ac70bb0.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710749316/248a655a-a3c0-4b95-9187-cd0cf2328524.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710862173/8160ae21-f782-45df-9ffd-c1a26e73677c.png align="center")

Install PHP and MySQL module:

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686710954137/53651c37-abf3-4291-8577-e31dff2b0167.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686711033353/ed946a48-f258-44f1-b99e-7b67fb1c2d24.png align="center")

Restart Apache again:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686711083263/99234ac4-5772-4029-82ef-3f54a84b3bd3.png align="center")

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686711122107/9d7a717e-67e4-4453-a046-3385c0665eac.png align="center")

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!
