Using RDS and EC2


In this article I am going to show how to use EC2(Elastic Cloud Computing) and RDS(Relational Database Service) service provide amazon together to setup pre created WordPress application.

In this article I am going to show how to:-

  • Creating an MySQL Database server using RDS.
  • Creating an EC2 instance.
  • Configure installing Apache Webserver.
  • Downloading WordPress.
  • Provide the endpoint/connection string to the WordPress Application.

By this article we are comfortable to use EC2 and RDS together to create an even complex Web Application

For this article I am assuming that you have windows 10 running that already setup AWS command line interface to do the work

Configuring MySql Server

Step 1:- Creating MySql over RDS

Open Command line and type the following command to create rds

aws rds create-db-instance ^
--db-instance-identifier test-mysql-instance ^
--db-instance-class db.t2.micro ^
--db-name dbforphp ^
--engine mysql ^
--master-username admin ^
--master-user-password admin12345 ^
--allocated-storage 20 ^
--availability-zone ap-south-1a ^
--vpc-security-group-ids sg-07a31fa1eb8bb4d02 ^
--no-publicly-accessible ^
--max-allocated-storage 21

^:- bat symbol is used when we want to write command in more that one line in same as (/ is bash)

db-instance-identifier:- is unique name given to every db instance

db-instance-class:- instance type we want to use

db-name:- it create the db name inside newly created db instance

engine:- is same vendor

master-username:- user of db server of the db

master-user-password:- password of db server

allocated-storage:- initially storage to db

availability-zone:- availability zone in which we want to create our db

vpc-security-group-ids:- id of one or more security group

no-publicly-accessible:- we want to create our db private so that no one can access form outside world

max-allocated-storage:- the amount of storage that we want to give after initially amount in consumed

as you can see the db instance is creating in mean time let go and configure WordPress

Step 2:- Creating EC2 instance

Now use following command to create ec2 instance

aws ec2 run-instances ^
--image-id ami-04b1ddd35fd71475a ^
--instance-type t2.micro ^
--subnet-id subnet-7a2a2312 ^
--key-name egkey ^
--security-group-ids sg-07a31fa1eb8bb4d02

image-id:- id ami(amazon image)

instance-type:- same as instance class

key-name:- name of the key to connect to the internet

subnet-id:- in which subnet we want to create our nstance

security-group-id:- is of the security group

copy instance id save some where for further use i-0c5a486878ffc190e

Step3:- Connecting to EC2 instance

Now run the following command

aws ec2 describe-instances --instance-id i-0c5a486878ffc190e | findstr PublicIp

to find the public ip address of the ec2 instance

copy public ip (in my case is open putty and connect to ec2 instance

Step4:- Installing necessary things

Now go to aws and install the software that we need by following command

yum install php-mysqlnd php-fpm mariadb-server httpd

and also run this command to install additional package

amazon-linux-extras install php7.3

now install WordPress by following command

curl --output word.tar.gz

and un tar it by following command

tar xf word.tar.gz

go to word folder by cd wordpress/ command

and copy everything's from word to /var/www/httpd by cp -r * /var/www/html command

and run systemctl enable httpd --now command to start the httpd service

now go to ip and you can see WordPress application is running

Step5:- Final Setup

Now go command line to retrieve the end point of our db instance by following command

aws rds describe-db-instances  --db-instance-identifier test-mysql-instance | findstr Address

copy address (in may case is and go back to web browser

Now click on Let’s go button and fill the information accordingly

and click on submit

look like some kind of error comes but don’t worry copy everything written in code box and save in file name wp-config.php

and copy the same file in /var/www/html folder of ec2 instance once you have done reload the site

click on installing now

now you can see this WordPress is running without any problem

Closing Note

In this article I used pre configured application but this same particle can be used with any application even if we create thing from starch

Thank for everyone to read my article till end if you have any doubt please comment if you have any suggestion please mail all comment both positive and negative is more than welcomed

Contact Detail

LinkeDin []

Additional Tags

#vimaldaga #righteducation #educationredefine #rightmentor #worldrecordholder #linuxworld #makingindiafutureready #righeducation #arthbylw #php #apache #wordpress #aws #rds #mysql #rdbms

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Colorize kubectl output by kubecolor

Email finding tools for Sales and Marketing teams

How to use synchronization commands while recording

In this part, I will prepare the project based on the kit’s demo, by duplicates init scene which…

HTTPS or bust: Chrome’s plan to label sites as “Not Secure”


Python Memory Optimisation -Slots

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Suyash garg

Suyash garg

More from Medium

How to Resize AWS Nitro-based Instance Type — Use Case: M4-M5

How to reduce your AWS Cost -Part 2

Simple Steps to Add Cloudwatch Metric

All About AWS Management Tools