how to deploy WordPress applications on an ec2 instance with Aws RDS

 I am going to give you complete step-by-step guidance on how to deploy WordPress applications on an ec2 instance with Aws RDS and talk about WordPress and Amazon RDS Services

What Is WordPress?🕸️

WordPress is a free, open-source website creation platform. On a more technical level, WordPress is a content management system (CMS) written in PHP that uses a MySQL database. In non-geek speak, WordPress is the easiest and most powerful blogging and website builder in existence today.

What Is Amazon RDS?☁️

Amazon RDS is a service that provides database connectivity through the Internet. RDS makes it very simple and easy to set up a relational database in the cloud.

Instead of concentrating on database features, you can concentrate more on the application to provide high availability, security, and compatibility. RDS is a fully managed RDBMS service.

Now, let’s dive into the steps:🏃‍♂️

Pre-requisites

· Must have an account on AWS

Now we are ready to go.🙂

🔶Step 1: Create an AWS EC2 instance

Login to AWS Account.

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

Click on Launch Instances

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

Select AMI

b) Click next and Select the Instance Type. I’ll go for the default one.

Select Instance Type

c) 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.

Attaching key

d) 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.

Add Security Group

e) Add Storage

f) Review and Launch

Here we can see, the instance is up !!

Instance launched🤩

So step 1 is done. Now move to 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

1. Using the browser

2. Using ssh

3. Using software like GitBash etc

Here I am using GitBash. You can choose any one of the above.

Connect to the instance

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 the 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, that it is successfully configured🤩

Home Page of Apache webserver

🔶Step 3: Download the PHP application name “WordPress”.

1. Install PHP

yum install php php-devel php-fpm php-mysqli php-json php-mysqlnd

then Run the Command

rpm -q php8.2

We can see the installed version of PHP using the below command

php -v

🔸Download and extract the software

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

check the WordPress

🔶 Step 3. Upload the WordPress files in the root directory of the webserver

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

 mv 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

Successfully Installed🎉

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 MariaD or other databases as per the requirement.

🔶 Step 4: Set up a MySQL server using AWS RDS service using Free Tier.

Go to AWS RDS Service →> Create Database

Select MySQL Engine

Templates ->> Free Tier ( You can select as per your requirement )

Settings ->> Set the Database name, Database User Name, and the password

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

Set the Instance configuration

then set the Storage autoscaling

Connect to ec2-user

Set the security firewall

Give the database a name!

And Off the automated Process(backup and upgrade)

I Go for the default settings and create the Database for this task.

Database

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

🌼After successfully creating the database run the following command on your terminal🏃‍♂️

cd /var/www/html
ls
cd wordpress
cp wp-config-sample.php wp-config.php
vim wp-config.php

🔶 Step 5: Provide the endpoint/connection string to the WordPress application to make it work

Go to this file and give the information of the database

and then restart the webserver

systemctl restart httpd

After restarting the page you join on this page and installing now

🌷Set Some Basic Information and click on Installation.


Login to WordPress🙂


🌟After Successfully Login you will see the Dashboard of WordPress

Now we can write blogs and post them.🫡

Conclusion💐

Deploying WordPress on AWS EC2 with RDS may require some initial effort, but it offers scalability, security, and reliability for your website. By following this step-by-step guide and continually learning about AWS services, you’re well-equipped to manage and grow your WordPress site with confidence in the AWS cloud environment. Remember that AWS offers extensive documentation and resources for further exploration and optimization of your infrastructure. Good luck with your WordPress project!

Comments

Popular posts from this blog

Adding Fun and Whimsy to Your Linux Terminal with Figlet, Cowsay, Nyancat, and More!

Leveraging Jenkins for Industry Use Cases: A Comprehensive Guide