Deploy WordPress with Amazon RDS Backend…

Sourabhmiraje
5 min readJan 11, 2021

Hello folks, in this article we are going to see how we can host the WordPress app on aws ec2 with Amazon RDS MySQL backend.

Task Description📄

🔅 Create an AWS EC2 instance

🔅 Configure the instance with Apache Webserver.

🔅 Download php application name “WordPress”.

🔅 As wordpress stores data at the backend in MySQL Database server. Therefore, you need to setup a MySQL server using AWS RDS service using Free Tier.

🔅 Provide the endpoint/connection string to the WordPress application to make it work.

So lets jump to the practical,

Part1:

In first part we will create RDS MySQL Database instance.

Select Standard method and MySQL as DB.

As of now we are using free tier for practice purpose.

Set the master user and password for connection.

Remember the credential (Better to write it down)

For now I am giving public access to the Database instance.

I am attaching new security group for instance. by default MySQL port is 3306, we can change if we want.

This will create mydb database while initializing.

Remember this name as well, we need while installing WordPress.

Enable Deletion protection in order to avoid the deletion of Database later in any case.

Then Proceed to create Database.

This will take some minutes to create.

Now we are Done With first part, if DB get created successfully.

2 Part:

In this part we will launch our WordPress app on ec2-instance.

Launch one Amazon Ec2 instance.

Select other things as per your requirement.

While creating new security group we need

  • http rule allowed for client to connect
  • MySQL/Arrora rule (i.e. port 3306) allowed toconnect our Database to our instance.

For this rule I am allowing to the same security group which I am attached to our Database instance, so that only that instance can connect.

  • ssh, because we need to go inside instance for some configuration.

After lunching the ec2 instance successfully, do ssh to the system.

Install httpd and mysql.

sudo yum install httpd mysql -y

sudo service httpd start

Connect to the mydb Database by using the master username , password and endpoint to the RDS database.

CREATE USER ‘your_user_name’ IDENTIFIED BY ‘mypass’;
GRANT ALL PRIVILEGES ON mydb.* TO Sourabh;
FLUSH PRIVILEGES;
Exit

Download WordPress from Command line:

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

Unzip the package:

tar -xzf latest.tar.gz

Then Go to Wordpress Directory

cd wordpress

we need to update configuration file.

Wordpress by defualt looks for wp-config.php file for configuration.

We need to create the same file with wp-config.php name and need to update.

we will copy the same file to create the new file with same content.

cp wp-config-sample.php wp-config.php

Also need to update the secret access key.

you can get this from here:

https://api.wordpress.org/secret-key/1.1/salt/

then replace

We need some additional extension for wordpress. run this command to install.

sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

then go to the directory where we have extracted the WorPress app

cd /home/ec2-user (in my case)

Move it or copy to the /var/www/html root

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

sudo service httpd restart

Now we done our second part successfully.

Lets check is it working or not…

Yeah !!!

We done successfully…

Now Set Up the WordPress and Done.

Final Output…

Hope this was helped…

Let me know in comment.

Any suggestion or modification always appreciated.

Thank You for reading…

Here is My LinkedIn Profile…

--

--