DevOps Tooling Website Solution

DEVOPS TOOLING WEBSITE SOLUTION

A DevOps team utilizes various tooling solutions in order to help the team carry out their day-to-day activities in managing, developing, testing, deploying and monitoring different projects.

In this project, we will be implementing a DevOps solution that consists of the following components

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 EC2 instances

  4. Webserver Linux: Red Hat Enterprise Linux 9

  5. Database Server: On Ubuntu 22.04+ MySQL

  6. Storage Server: Red Hat Enterprise Linux 9 +NFS Server 7) Programming Language: PHP

  7. Code Repository

  8. Internet connection

IMPLEMENTATION STEPS: Set up of all EC-2 instances.

i) Ensure you log in with your details to your AWS console via the
ii) Click on the EC2 link and spin up 5 EC2 instances and make sure they are set up with the operating systems below 4 Red Hat Enterprise Linux 9 Operating system (free tier) comprising of One NFS server and 3 webservers.You can see the instance state that shows all 5 servers are currently running. The names are

NFS Server , WebServer1, WebServer2, WebServer3

image1

1 Ubuntu Operating system comprising of the Database server. The name is DATABASE-SERVERUB

image2

Then we proceed to configure the NFS Server

NFS SERVER CONFIGURATION

We 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 connect the ssh and type yes and once the connection is successful, we proceed to name the nfs server. This is so that we can be able to distinguish each server by their names and avoid confusion with another server we would be configuring.The server name was edited as shown below

image3

This is also done in the webserver 1 and 2 as seen below.

image4

image5

The next step would be to go back to the AWS console and click to create the volumes. You must also check the availability zones as they play a crucial role in the location in which the volumes are created. Ensure the sizes are 10 gig and create volume as seen below.

image6

image7

image8

image9

Repeat the same steps for the other 2 volumes. Navigate to the volume created, Choose the instance you are attaching to (NFS SERVER ) attach volumes and start using them.

image10

Navigate back to the terminal and type the lsblk command to see the EBS volumes we attached. Uses the command below to partition the drive and use the help command to see the options available to add a new partition.

image11

Type "n" to add a new partition, Choose 1 as the partition number Click the enter button for the first and last sector. Enter :8300 for the default file system as shown below

image12

You can type "p" to view the partition table as shown below.

image13

We use "w" to write the table and edit on the disk Type "w" and click enter Type "y" to proceed.

image14

It states that the operation was successful.

image15

Type lsblk command to check again and you will see that the xvdf file now has where the partition was created as seen below

image16

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

image17

image18

Proceed to install the lvm2 package.

image19

After that is successfully installed, we use the lsblk command to check our 3 partitions created

image20

Create a physical volume using the pvcreate command for the xvdf1, xvdg1 and xvdh1 respectively

image21

Use the lsblk command to check the 3 physical volumes created

image22

Use the pvs command to check the 3 physical volumes.

image23

We then use the vg-create command to let the 3 physical volumes be seen as 1 logical volume and we name is webdata-vg as shown below

image24

Use "vgs" to check if it was implemented successfully.

image25

The next step would be to create 3 logical volumes apps, logs and opt as shown below and confirm it was implemented successfully

image26

Using the lsblk command to view all we have done since starting the partition creation, we can see the full detailed structure created as shown below

image27

We need to format the extra metadata that came along with this volume with the mkfs command below.

First, we check the devices using the /dev command

image28

And format the 3 logical volumes (command apps, logs and opt) with the mkfs command

image29

While in the NFS server, we are to create some mount points on the mount directory on the logical volumes. We created the 3 directories as shown below and check it was created successfully.

image30

We would then mount the 3 logical volume path with the 3 mounting points as shown below

image31

The next step would be to install the NFS server. Please take note that this is the place we store all the data and by storing it , the webserver automatically becomes the NFS client.

The installation of the NFS SERVER is done with the commands below

image32

NFS server installation is completed, enabled and actively running.

image33

Press q to quit and get back on the terminal

The next step would be to export the mount for web servers from subnet cidr. Click on the networking button and then proceed to click the subnet ID link as shown below.

image34

image35

The ipv4 cidr is shown below

image36

Please note: The lower the number of cidr the higher the number of computers that can gain access to that server. This can connect 4096 computers and shows the importance of cidr. Copy the cidr for future use.

We then navigate back to give permissions to allow our webservers access to read, write and execute. We can give permission to root or simply say nobody. In this case we would say nobody because we want everyone to have access to it and it is not own by anyone.

Before the permission was changed

image37

After permission was allowed. see below as permission has been granted to nobody as well as the chmod 777 permission.

image38

We would then proceed to restart our NFS server after mounting of the logical volumes.

We then proceed to configure access to NFS from our clients within the same subnet ipv4 cidr as shown below.

image39

Paste the code below in /etc/exports, Save and quit to get back to the terminal

image40

Verify they are properly mounted successfully with the command below.

image41

The next process is to go back to AWS security group for NFS server to open the ports tcp and udp via the inbound rules

image42

Click security and security group

image43

Add all rules.

image44

Including the subnet cidr block of the webservers to access the NFS server.

image45

Added successfully

image46

Now we proceed to the next stage to configure the database server.

DATABASE SERVER CONFIGURATION

To configure our database server, we would install MySQL server and also created a hostname for the ip address for easy use.

image47

To access the MySQL environment, we use the command below

image48

but when we exit it, we need to use this

image49

The next thing would be to create a database. Let's show the current state of the database and it is as shown as below

image50

To use and show all tables in the MySQL ,

image51

We would be creating the following and ensuring the ipv4 cidr is included when creating the database server.

i)Database name: tooling ii) Database username: web-access

We would be using authentication by granting all privileges to web-access from tooling including all tables in it.

image52

Now lets proceed by flushing the privileges and showing the database to see if we successfully created the databases.

image53

Type: "Use tooling" to activate the database and show tables

image54

image55

The new user called web-access is shown below.

image56

Now we navigate back to the webservers.

WEBSERVERS

We would be working on the 3 webservers but also note that they would also represent as an NFS client to our NFS server when it stores information. We intend to display the web page on the web server. We want to be able to read and write on the web page and we intend to gain access to /var/www to retrieve the html

We would proceed with the first step by configuring the NFS CLIENTS on all 3 servers.

We have to update the package manager

image57

And install nfs-util

image58

Then we must create the /var/www directory and then mount the path where we would be installing the APACHE server (httpd).

Mounting is where we would be doing the connection linking the NFS CLIENT (Webserver)and the NFS server

We should check the hard disk df -h command to check how much disk is available on the computer.

image59

To confirm if the mounting was successful we can try an experiment by changing directory to /var/www , and checking its content which should be blank, proceed to create a file name testfile .

image60

Navigate back to NFS server. Change directory to /mnt and check its content. You will find the file test file there .

image61

This confirms that our NFS CLIENT has been successfully connected to store information on the NFS SERVER.

Please note that when you reboot this server it would not retain the connecting state and the connection will be lost but to make it connect constantly we need to modify the fstab file .

image62

image63

Proceed to install Apache and PHP from a third party Remi's repository is shown below

image64

Install Apache

image62

Installation continued and type y

image65

image66

All our packages are installed then we check if PHP is available on our repository version 8.1 which is a better upgrade
compare to 7.4

image67

You can still run the command without the: remi-7.4 to get the installation and click yes

image68

image69

Then we proceed to install the PHP and type y and click enter

image70

image69

We then proceed to start PHP and enable it and check the status to know if it is running . This can be seen below

image71

Next is to set a Boolean and ensure that port 80 is opened.

image72

Run the mount command and check the df -h command below

image73

You can now start the httpd and check status as well.

image74

Enable the httpd

image75

We can check the webserver and copy the public Ip address.

image76

We have been able to configure the server successfully.

We have to locate the log folder for apache httpd on the webserver.Change the directory to /var/log and check its content, then you can change the directory to httpd

image77

Please note if all troubleshooting fails, always remember selinux to help you out in terms of permission

Run the mount command and check the df -h command below

We should make sure we mount the /mnt/logs on /var/log/httpd and add this file to the fstab. This is important for rebooting as well to keep the connection available at all times making sure there is persistence.

See below

2023-09-08 07_24_55-DevOpsToolingWebsiteSolution pdf and 5 more pages - Personal - Microsoft​ Edge

image78

image79

We now proceed to create a fork repository to retrieve the source code from the git hub account.

First, install git on the webserver

image80

Once installed then you clone the https repo.

image81

Then you proceed to deploy the website code into the webserver. Change the directory into tooling and check its contents.

Then we should copy all files in the tooling directory into the var/www/html file.

From the tooling directory, Change directory to var/www/html and view the content to the see copied files from the tooling shown below.

image82

From the html directory change directory into /etc/httpd/conf.d and use the cat command to view the welcome.conf file.

image83

We would now edit the functions.php file in the html folder.

image84

This helps us connect the application to the database. We insert the database private IP, database username , password and database name as shown below. Please note this only needs to be configured on one of the servers and then its connected.

image85

Then we proceed by applying the tooling-db.sql script to our database using the command below. When entering the data we can only put the database private ip , database username and database name but not the password as it is confidential,so we would leave it blank and would be executed. We are going to install MySQL client because the action would be taking place on the webserver

image86

So, we proceed by writing the command

image87

Check blkid to view the id .

image88

image87

Then we launch out ip addresses for the 2 servers and it is

successfully displayed

image89

image90

We would go further to type in the details for the username and password and they both are successfully logged

image91

image92

Finally, we have successfully implemented a web solution using LAMP stack with remote databases and NFS Servers.

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

Thank you for reading💚👏