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:
Configuration of storage systems focusing on working with disks, partitioning and creating volumes on Web and Data servers using the Linux Operating system
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.
Fundamental Knowledge of Installing and downloading software
Basic Understanding of Linux Commands
AWS account login with 2 EC2 instances (Red Hat)
Webserver (WORDPRESS
Laptop or PC to serve as a client.
Database Server (MYSQL database server)
Internet connection
IMPLEMENTATION STEPS:
Ensure you login with your details to your AWS console via aws.amazon.com
Click on the EC2 link to create instances.
iii)Click on launch instance dropdown button and select launch instance.
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 .
Click on the “Create new key pair” link and ensure the Checkbox remains unchanged on the “Create security
group”
Select 2 instances and Launch both instances
Instances are successfully launched as shown below
Then we name the 2 instance webserver and database respectively .
The public ip address of both servers are displayed below
Click to connect to ssh
We then proceed to check the availability zone of our server and click add volumes.We are to create 3 volumes
Select 10 Gib and the availability zone and click to create volume
After creating the 3 volumes we refresh and can see them below.We name them web1,web2,web3 respectively
Then we now attach each of the 3 volumes to the webserver as seen below
All 3 attachments are seen below and are now ready for use
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
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
With the df -h command we can see the mount point available
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 .
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 ,
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.
Repeat the same steps and create the partition for g and h partitions and the results are shown below
Type lsblk command to check again and you would see that the xvdf1,xvdg1,xvdh1 files has been created .
We then proceed to install the lvm2 package.
Next step is to create a physical volume using the pvcreate command for the xvdf1, xvdg1 and xvdh1 respectively
We use the lsblk command to check the 3 physical volumes created
Use the pvs command to check the 3 physical volumes.
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
Use “vgs” to check if it was implemented successfully.
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
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
Use pvs to check whats left of the gig size (1.99)
And format the 2 logical volumes (command apps and logs) with the mkfs command
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
We can see the folder and file created .
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 .
You can now proceed to mount and use the df -h command
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 .
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
And with this you can see that the folder has been backed up
Proceed to mounting
The command below shows that it has been properly mounted
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
We are going to copy the UUID for the lv-apps and lv -logs and go back to our terminal.
We have update the fstab and also reloaded the daemon
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
Select 10 Gib and the availability zone and click to create volume
Refresh to see all volumes created and name them db1,db2,db3 respectively and see they are available
Then we now attach each of the 3 volumes to the webserver as seen below
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
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.
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
With the df -h command we can see the mount point available
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 ,
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.
Type lsblk command to check again and you would see that the xvdf1,xvdg1,xvdh1 files has been created
Repeat the same steps and create the partition for g and h partitions and the results are shown below
We then proceed to install the lvm2 package.
Next step is to create a physical volume using the pvcreate command for the xvdf1, xvdg1 and xvdh1 respectively
We use the lsblk command to check the 3 physical volumes created
Use the pvs command to check the 3 physical volumes.
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
Use “vgs” to check if it was implemented successfully.
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
Use pvs to check what’s left of the gig size (9.99)
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
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
Then we mount it and also confirm If it has been mounted with the df -h command
(Using blkid command )
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
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
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
Then we enable and start apache httpd
Then we proceed to install the PHP and its dependencies
We then proceed to list and reset and enable the PHP
Start, enable and set Boolean value for Apache as shown below
Restarting Apache
Apache status and confirm there is no file on the /var/www/html location
We proceed to create and change directory to WordPress and install it with its dependencies.
Downloading in progress and finally completed .Configure selinux policies as well
Go back to your database server to complete the installation and configuration.
Installing MySQL on database server, restart, enable and check status
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 .
Please note that when we check the user you would get this
We need to set the bind address :
The next step would be to configure WORDPRESS which is the webserver to act as a client to connect to the remote database
Launch on the browser
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💚👏