WordPress Deployment On EC2 Instance And Use RDS For Database

Himanshu Agrawal
3 min readMar 5, 2021

--

In this article we will deploy WordPress on AWS EC2 Instance and we will use AWS RDS Service For Database . In AWS RDS We will use MySQL Database .

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.

Create Security Group & Allow 22 , 80 ,3306 Ports -
* aws ec2 create-security-group — group-name MySecurityGroup — description “My security group”

* Allow port 80
aws ec2 authorize-security-group-ingress — group-name MySecurityGroup — protocol tcp — port 80 — cidr 0.0.0.0/0

* Allow port 22
aws ec2 authorize-security-group-ingress — group-name MySecurityGroup — protocol tcp — port 22 — cidr 0.0.0.0/0

* Allow port 22
aws ec2 authorize-security-group-ingress — group-name MySecurityGroup — protocol tcp — port 33076— cidr 0.0.0.0/0

Launch EC2 Instance -
aws ec2 run-instances — image-id ami-052c08d70def0ac62 — count 1 — instance-type t2.micro — key-name MyArthKey — security-group-ids sg-01b33e2b5c84ea0ce

  • Run below command to setup wordpress — ( I have these command in a file “install” now I will run this file “install”)
  # yum install httpd -y
# systemctl enable httpd --now
# amazon-linux-extras install php7.3 -y
# wget https://wordpress.org/latest.tar.gz
# tar -zxf latest.tar.gz
# cp -r wordpress/* /var/www/html/
# systemctl restart httpd
  • Make executable this file and run this file -
# chmod +x install
# ./install
  • Check WordPress is running or not ( In my case it is running file if WordPress site is not showing then restart httpd service ) -

Run below command to create Database ( “database2” )Cluster using AWS RDS Service

# aws rds create-db-instance --availability-zone ap-south-1b --db-name database2 --db-instance-identifier testing --vpc-security-group-ids sg-001cad109816edeee --engine mysql --engine-version 5.7.31 --master-username admin --master-user-password redhatadmin --publicly-accessible --db-instance-class db.t1.micro --allocated-storage 20

SetUp WordPress -

  • Give Info to WordPress -
  • Put copied code in “/var/www/html/wp-config.php” at EC2 Instance where WordPress is deployed -

Our WordPress Site is successfully deployed. Now Task is competed.

--

--

No responses yet