WordPress configuration over AWS with Amazon RDS
Tags: linux, aws, wordpress
Published: 2021-03-16 18:15:43

Hello everyone,

In this blog, we will be configuring WordPress over AWS and will use AWS RDS as a backend for WordPress

Tasks that we will be performing include:

- Create an AWS EC2 instance
- Configure the instance with Apache Webserver.
- Download PHP application name “WordPress”.
- Setup a MySQL server using AWS RDS service using Free Tier.
- Provide the endpoint/connection string to the WordPress application to make it work.

Before we get started with our tasks first let's understand :

# What is 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.[source](https://aws.amazon.com/rds/)


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbbwu20k1d4njubl77i1.png)

## Create an EC2 instance

- To create an EC2 instance go to **services** and select **EC2**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz6sgj7sqo6nu4t0zueh.png)

- Now click on the **Launch instance**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hopgjqatfmvb0gfawk6f.png)

- For this demo, we will use **Red Hat Enterprise Linux 8**

So click on the select

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zy206fq4vdh5jx06rc13.png)

- Select **t2 micro** as instance type as it is free tier eligible 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ehnrissrz9oeboftp9yy.png)

Now Click on **Next:Configure instance Detail**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/59lgdebmyqi4rgz4x212.png)



Now click on Add storage

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/75hch33l6jb1bbanx42c.png)

Now click on Add Tag

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/illeq4ehxvhnuswkfwpf.png)

Now click on **Click to add a Name tag**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rhtzn9j803u0xjlerala.png)
Give tag to your instance in value field, here I have given tag named **WebApp**

Now clink on **Next: Configure Security Group**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aowrdwsdsdjau4ooo3gk.png)

In type dropdown select **All traffic** so that firewall can allow all traffic though it is not good practice, we are using it for the demo.

Now click on **Review and Launch**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/craj003ocqi34w1o1jtx.png)

Now click on **Launch** and then select your key and click **Launch instance**

Now click on the instance id

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ln7pz7ynd84qtxjthzom.png)

Now you can see that EC2 instance is launched successfully

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oiiguxcgnrzv0ej9yuut.png)

## Create Database

- Again to service and search for **RDS**

Click on **RDS**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s3say1qxd6bvk170owip.png)

Now click on **Create database**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aidsfbyw125x7cmslzsm.png)

Now select **Standard create** and Select Engine **MYSQL**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nkqfquy3ahcyp2q84da3.png)

Here I am using MYSQL version as **MYSQL 5.7.31** and select template as **Free tier**

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/po5rm2ykncrjjbm8nxaz.png)

Now give the database name here I have given the name as **WordPress** and give the password to your account 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6k6tyah7rr1j819zbvsh.png)

Now give the public access to your database and click in **Create Database**

Now you can see our database is created

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rumxzo2d9a4k8rdexo02.png)

- Now run the EC2 instance that we created

Now update the repo by running the command `dnf update -y`

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5qni3l323y02bez2w0u.png)

- Now install fedora rpm for further software

To install fedora rpm use command `dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm`

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fn70wv0g8gxy4sv5mbv5.png)

- Now install wget software to download packages from internet

To download wget use the command `yum install wget -y`

- Now configure Apache webserver 

To install an apache webserver use the command `yum install httpd`

- Start the Webserver

To start the webserver use command `systemctl start httpd` and to check the status of web server use the command `systemctl status httpd` 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2jfnuspbdc9zvngxvos7.png)

- Now install PHP software

To install PHP use commands `dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm` , `dnf module install php:remi-7.4` and `dnf install php-mysqlnd`

- Now install the Mysql database

To install MySQL use the command `dnf install mysql -y`

## Connect RDS with an instance

To connect RDS with instance use command ` mysql -h <Database Endpoint> -u <username> -p`

To check the Endpoint click on the database scroll down and you will find Endpoint.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ktvytv62zgmz8pbglxwk.png)

Now Database has been connected with the instance 

- Now download WordPress files 

To download WordPress file use command `wget http://wordpress.org/latest.tar.gz` and to unzip the file and copy in root directory use command `tar -xvzf latest.tar.gz -C /var/www/html`

## Configure the WordPress

- Go the root directory `cd /var/www/html/wordpress`

- edit the file `wp-config-sample.php`

add your database name,  username, password and hostname

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ws01nwykwvxl2hqvwt1.png)

## Open WordPress in browser

To open WordPress in browser add your public ip of instance with the dir name that is **PublicIp/wordpress**

Now you will see the WordPress page


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwu9qwsbat89d2h9ln0w.png)

Now add credentials and start blogging

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2tzlf00oj9r5bzpd0y3i.png)


Thank you !!✨