Deploy WordPress Website On AWS

Deploy WordPress Website On AWS

#90 Days of DevOps Challenge - Day 45

Over 30% of all websites on the internet use WordPress as their content management system (CMS). It is most often used to run blogs, but it can also be used to run e-commerce sites, message boards, and many other popular things. This guide will show you how to set up a WordPress blog site.

Task-01

  • As WordPress requires a MySQL database to store its data, create an RDS as you did on Day 44

  • To configure this WordPress site, you will create the following resources in AWS:

  • An Amazon EC2 instance to install and host the WordPress application.

  • An Amazon RDS for MySQL database to store your WordPress data.

  • Set up the server and post your new WordPress app

Step 1:- First we need to create an EC2 instance and since we are going to use MYSQL so we need to allow port 3306

Step 2:- No we need to create a Free tier RDS instance of MySQL. We need to search Amazon RDS-> Create database.

Then In Enginee options need to choose MySQL

need to Choose the "Free tier" template

Now we need to select the name

Need to Set the "Master username" and "Master password" for the database

Instance Configuration and Storage need to select

Select the Connectivity, compute resource as EC2 compute resource

Now we need to select VPC security group and click on Create database

Once it will create it will show like the below screenshot

Step 3:- Now we need to Create an IAM role with RDS access

Now we need to go IAM service and click on roles and need to choose AWS service -> select EC2 and click on next

now we can select AmazonRDSFullAccess and click on next

after creating create a role it will look like below screenshot

Step 4:- Now we need to Assign the role to EC2 so that your EC2 Instance can connect with RDS

Need to click on Actions->Security->Modify IAM role ->

select IAM which we created and click on update IAM role

Step 5:- Once the RDS instance is up and running, get the credentials and connect your EC2 instance using a MySQL client.

Now we need to go inside the EC2 machine and need to install the mysql client by following the below command

sudo apt install mysql-client-core-8.0

Once installed completed we can check MySQL is installed or not by running the below command

mysql --version

Connect to the RDS instance using the MySQL client and the endpoint address, username, and password:

Get the Endpoint & Port from the Connectivity & Security of RDS

mysql -h <endpoint address> -P <port.no> -u <username> -p

# Ex:- mysql -h my-rds-sql.ctsxxmdfwhqv.us-east-1.rds.amazonaws.com -P 3306 -u admin -p

After giving the password it will be like this

Word press DB creation and Apache server installation.

Step 1:- Firtly we need to create a database user for the WordPress application and give the user permission to access the WordPress database.

CREATE DATABASE wordpress;
CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-99';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
FLUSH PRIVILEGES;
Exit

Step 2:- To run WordPress, you need to run a web server on your EC2 instance.To install Apache on your EC2 instance, run the following command in your terminal:-

sudo apt-get install apache2

then we need to start apache2 byrunning below command

sudo systemctl restart apache2

Step 3:- Now we need to check from the browser

Set up the server and post your new WordPress app

  • Download and uncompressed the WordPress software by running the following commands in your terminal:-
wget https://wordpress.org/latest.tar.gz
  tar -xzf latest.tar.gz

  • Now we need to go to the WordPress directory and create the default config file using the following command

  • Now create a copy of the config file and edit the wp-config.php file
sudo cp wp-config-sample.php wp-config.php
sudo vim wp-config.php

  • Edit the database configuration by changing the following lines:-

  • Before running a WordPress application we need to install a dependent application.

      sudo apt install php libapache2-mod-php php-mysql -y
    

  • Now, we need to copy WordPress application files into the /var/www/html directory
sudo cp -r wordpress/* /var/www/html/

and then we need to restart the apache2 server by running the below command

sudo systemctl restart apache2
  • Now we need to access the application through the browser
public-ipv4address/wp-admin/
#Ex:- 44.211.138.165//wp-admin/

Devops#devops,#90daysofDevOps

Thank you for reading!! I hope you find this article helpful!!

if any queries or corrections to be done to this blog please let me know.

Happy Learning!!

Saikat Mukherjee

Did you find this article valuable?

Support Saikat Mukherjee's blog by becoming a sponsor. Any amount is appreciated!