Deploy WordPress Application on Ec2 Instance with AWS RDS

Task Description
Let’s Begin the Task !

Step 1 : Create an AWS EC2 instance

Login to AWS Account.

Go to EC2 Dashboard ->> instances ->> Launch Instance


a) Select an AMI. Here I am selecting Amazon Linux 2 AMI.


Select AMI
b) Click next and Select the Instance Type. I’ll go for default one.
C) Configure Instance Details
D)Add storage
E) Add Tags

Here we can create multiple tags like name, env etc. These tags are helpful to specify the instance.

f) Configure Security Group — Here I am adding one more rule for HTTP and allowing everyone to connect with the instance.

Note: It is not a good practice to allow everyone. We must create custom rules for the security of our instances.

( I have done this just for the demo )

g) Review and Launch

Now, If we want to connect with this instance using the ssh protocol we need a key so here I am attaching an existing key. You can create a new one.

Here we can see, the instance is up !!

So the step 1 is done. Now move to the step 2 ..

Step 2 : Configure the instance with Apache Webserver

Let’s connect with the instance. There are so many ways to connect with the instance

Using the browser
Using ssh
Using the software like putty etc.
Here I am using the first way. You can choose any one of the above.
Note: All the images do not provide this option to connect.

Currently we login as ec2-user. This user doesn’t have the admin power so to switch with root user, run the below command

sudo su -
Let’s Configure Apache Webserver !!

a) Install the Software

yum install httpd -y
b) Start the service and make it permanent

systemctl start httpd
systemctl enable httpd
Here we can see, it is successfully configured

Step 3 : Download PHP application name “WordPress”.

Requirements

PHP version 7.4 or greater.
MYSQL version 5.6 or greater OR MariaDB version 10.1 or greater.
HTTPS support
Install PHP
To install php on Amazon Linux 2, we have to first install amazon-linux-extras package. ( By default, it is installed )

yum install -y amazon-linux-extras
Enable PHP 7.4 package

amazon-linux-extras enable php7.4
Now install PHP packages from the repository.

yum clean metadata 
yum install php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}
We can see the installed version of PHP using the below command

php -v
2. Download and extract the software

wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
. Upload the WordPress files in the root directory of webserver

Note: Here I am using Apache webserver so the root directory of the webserver is /var/www/html

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

WordPress is installed !!

We can check it by go to the url

http://<public_ip_of_server>/wp-admin/install.php
Here it will ask for the Database Information so we need to create a DataBase.

I am creating MYSQL Database using AWS RDS, you can use MariaDB or other databases also as per the requirement.

Step 4: Setup a MySQL server using AWS RDS service using Free Tier.

Go to AWS RDS Service →> Create Database

Select MariaDB Engine
Note: Whatever password you set for database, it should be remembered. As we need it in the future.

Give database a name !

Public Accessibility — yes
Security Group — AllowAll ( You can customize it )
I Go for the default settings and create the Database for this task.

Our database is created. We’ll use this endpoint to connect with wordpress.

Step 5: Provide the endpoint/connection string to the WordPress application to make it work.
Or we can manually write these information in the wp-config-sample.php file and rename this file with wp-config.php

mv wp-config-sample.php wp-config.php
Set Some Basic Information and click on the Installation.After Successfully Login you will see the Dashboard of WordPress
Now we can write the blogs and post them.












 
  




Comments

Popular posts from this blog

GUI container on the Docker. Launch a container on docker in GUI mode. Run any GUI software on the container.

Fun commands in Linux