Web Solution with Wordpress

WEB SOLUTION WITH WORDPRESS

In this project, we would be implementing a basic web solution called WordPress while creating storage infrastructures on 2 Linux servers

This project consists of two parts:

  1. Configuration of storage systems focusing on working with disks, partitioning and creating volumes on Web and Data servers using the Linux Operating system

  2. Deployment of Web and Database tier of Web solutions by

connecting WordPress to a remote MySQL server

It’s important to have the web server installed separately with WordPress as the CLIENT while we install the database server separately this helps us in

separating the 2 servers just to enhance security and avoid natural disaster recovery in case of any unforeseen circumstance so as to void losing so much information.

The pre-requisite for the projects is the following.

  1. Fundamental Knowledge of Installing and downloading software

  2. Basic Understanding of Linux Commands

  3. AWS account login with 2 EC2 instances (Red Hat)

  4. Webserver (WORDPRESS

  5. Laptop or PC to serve as a client.

  6. Database Server (MYSQL database server)

  7. Internet connection

IMPLEMENTATION STEPS:

  1. Ensure you login with your details to your AWS console via aws.amazon.com

  2. Click on the EC2 link to create instances.

image

iii)Click on launch instance dropdown button and select launch instance.

image

Select Red-Hat from the quick start option and note that amazon machine image selection varies from user to user .Select red hat enterprise Linux 9 HVM SSD Volume type .

image

Click on the “Create new key pair” link and ensure the Checkbox remains unchanged on the “Create security

group”

image

image

Select 2 instances and Launch both instances

image

Instances are successfully launched as shown below

image7

Then we name the 2 instance webserver and database respectively .

image8

image9

The public ip address of both servers are displayed below

image10

image11

Click to connect to ssh

image12

We then proceed to check the availability zone of our server and click add volumes.We are to create 3 volumes

image13

image14

Select 10 Gib and the availability zone and click to create volume

image15

image16

image17

After creating the 3 volumes we refresh and can see them below.We name them web1,web2,web3 respectively

image18

image19

Then we now attach each of the 3 volumes to the webserver as seen below

image20

All 3 attachments are seen below and are now ready for use

image21

WEBSERVER CONFIGURATION

Open git bash on visual studio code or whichever console is convenient to use. We are using git bash here with Visual Studio Code

We rename the ip address as webserver as seen below

image22

image23

Once all volumes have been attached you should run the lsblk command and you would be able to see all the 3 disks that have been created xvdf, xvdg and xvdh

image24

With the df -h command we can see the mount point available

image25

We have to create a partition on the physical disk. We use the gdisk function to create a single partition on xvdf, xvdg and xvdh.Please note all the devices are stored in /dev .

image26

We use the gdisk command as show below , Type “n” to add a new partition,

Choose 1 as the partition number and click enter button for the first and last sector .Enter :8300 for the default file system ,

image27

Type “p” to view the partition table. Use “w” to write the table and edit on the disk and type “w” and click enter and type “y” to proceed.Then it can be seen that the operation was successful.

image28

Repeat the same steps and create the partition for g and h partitions and the results are shown below

image29

image30

Type lsblk command to check again and you would see that the xvdf1,xvdg1,xvdh1 files has been created .

image31

We then proceed to install the lvm2 package.

image32

Next step is to create a physical volume using the pvcreate command for the xvdf1, xvdg1 and xvdh1 respectively

image33

We use the lsblk command to check the 3 physical volumes created

image34

Use the pvs command to check the 3 physical volumes.

image35

Volume groups is used to add together all physical volumes andmake them whole .We then use the vg-create command to let the 3 physical volume be seen as 1 logical volume and we name is webdata-vg as shown below

image36

Use “vgs” to check if it was implemented successfully.

image37

The reason the VSize is not 30g is because some little amount has been reserved for the disk itself if space are needed in the future

From this volume group we can now create 2 logical volume which we give to our servers to use on apps and logs and confirm it was implemented successfully

image38

image39

We can add 5g to the apps and logs by using this command for both of them as shown below and make them 14 gig each .Check and confirm it was implemented successfully

image40

Use pvs to check whats left of the gig size (1.99)

image41

And format the 2 logical volumes (command apps and logs) with the mkfs command

image42

Next, we are creating a mount point for our devices but to create a directory called www. we need confirm it is not existing already so we type the command below and we can confirm its not there and proceed to create the www directory

image43

We can see the folder and file created .

image44

We create another directory and folder (/home/recovery/logs) and mount the apps-lv device and place it on the directory (/var/www/html)

Please note that mounting means the data exist in both places .But you should always check the existing file to know its empty before performing the mount operation because it might lead to loss of data if you don’t check the file content .

image45

You can now proceed to mount and use the df -h command

image46

We have to check again for the logs file to investigate its content before mounting .As you can see there are 496 files which could have been lost if we proceed by mounting which makes it very mandatory to check as they are very important to our machine .

image47

The solution to this is by copying the files in /var/log into the /home/recovery/log file and you can confirm it by simply checking its content as shown below

image48

And with this you can see that the folder has been backed up

image49

Proceed to mounting

image50

image51

The command below shows that it has been properly mounted

image52

We should know that the mount is temporary and once the server is rebooted it would loose connection. We should ensure to make the connection persist and that would be by editing the fstab file and adding some crucial command to make it permanently stable

We check the blkid to check the commands we need to populate the fstab

image53

We are going to copy the UUID for the lv-apps and lv -logs and go back to our terminal.

image54

image55

We have update the fstab and also reloaded the daemon

image56

DATABASE SERVER PREPARATION

In this preparation we would launch a red hat instance for the DB server and repeat all steps and create a db-lv and mount It to a /db

We would create volume and also take note of the availability zone of the database server and create 3 volumes

image57

image58

image59

Select 10 Gib and the availability zone and click to create volume

image60

Refresh to see all volumes created and name them db1,db2,db3 respectively and see they are available

image61

Then we now attach each of the 3 volumes to the webserver as seen below

image62

image63

Repeat this steps for the rest of the volumes as seen below and all 3 volumes are now ready for use by the database server

image64

DATABASE SERVER CONFIGURATION

Open git bash on visual studio code or whichever console is convenient to use. We are using git bash here with Visual Studio Code

We rename the ip address as webserver as seen below.

image65

image66

Once all volumes have been attached you should run the lsblk command and you would be able to see all the 3 disks that have been created xvdf, xvdg and xvdh

image67

With the df -h command we can see the mount point available

image68

We use the gdisk command as show below , Type “n” to add a new partition,

Choose 1 as the partition number and click enter button for the first and last sector .Enter :8300 for the default file system ,

image69

Type “p” to view the partition table. Use “w” to write the table and edit on the disk and type “w” and click enter and type “y” to proceed. Then it can be seen that the operation was successful.

image70

Type lsblk command to check again and you would see that the xvdf1,xvdg1,xvdh1 files has been created

image71

Repeat the same steps and create the partition for g and h partitions and the results are shown below

image72

image73

We then proceed to install the lvm2 package.

image74

Next step is to create a physical volume using the pvcreate command for the xvdf1, xvdg1 and xvdh1 respectively

image75

We use the lsblk command to check the 3 physical volumes created

image76

Use the pvs command to check the 3 physical volumes.

image77

Volume groups is used to add together all physical volumes and make them whole .We then use the vg-create command to let the 3 physical volume be seen as 1 logical volume and we name is database-vg as shown below

image78

Use “vgs” to check if it was implemented successfully.

image79

The reason the VSize is not 30g is because some little amount has been reserved for the disk itself if space is needed in the future

From this volume group we can now create 2 logical volume which we give to our servers to use on apps and logs and confirm it was implemented successfully

image80

image81

Use pvs to check what’s left of the gig size (9.99)

image82

Next step is to create the mount point .We create a directory called “db” and create the file system using the mkfs command and then mount

image83

We know we created the file but lets check to see if it has any content .As you can see below it has no content

image84

Then we mount it and also confirm If it has been mounted with the df -h command

image85

(Using blkid command )

image86

Proceed to make sure that the connection is persisted and consistent even after reboot. We would be editing the /etc/fstab file to perform this action and confirm if success with the command below and have a system reload .Also check the df -h command to confirm its there in the information provided

image87

image88

Next step is to install word press on our webserver.

WORDPRESS INSTALLATION ON WEBSERVER

This installation should be done in the webserver .We have to run an update on the webserver and the database server .

But before then we have to update both servers as shown below

image89

We should check the security group of both instances to ensure they are all open to the traffic we want it to be.

We then proceed to install WordPress on our webserver. First ,Install wget,apache and its dependencies

image90

Then we enable and start apache httpd

image91

Then we proceed to install the PHP and its dependencies

image92

image93

We then proceed to list and reset and enable the PHP

image94

image95

image96

Start, enable and set Boolean value for Apache as shown below

image97

image98

Restarting Apache

image99

Apache status and confirm there is no file on the /var/www/html location

image100

image101

We proceed to create and change directory to WordPress and install it with its dependencies.

image102

Downloading in progress and finally completed .Configure selinux policies as well

image103

image104

Go back to your database server to complete the installation and configuration.

Installing MySQL on database server, restart, enable and check status

image105

image106

image107

Configure DB to work with WordPress

We would create a database named wordpress and create my user with your credentials and ensure you grant all permission and flush out privileges .Once done check the database tables and exit it .

image108

Please note that when we check the user you would get this

image109

image110

We need to set the bind address :

image111

The next step would be to configure WORDPRESS which is the webserver to act as a client to connect to the remote database

image112

Launch on the browser

website

Web solution launched successfully

If this post was helpful, Would be great if you could click the clap button 👏below to show your support.

Thank you for reading💚👏