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.
Fundamental Knowledge of Installing and downloading software
Basic Understanding of Linux Commands
AWS account login with EC2 instances
Webserver Linux: Red Hat Enterprise Linux 9
Database Server: On Ubuntu 22.04+ MySQL
Storage Server: Red Hat Enterprise Linux 9 +NFS Server 7) Programming Language: PHP
Code Repository
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
1 Ubuntu Operating system comprising of the Database server. The name is DATABASE-SERVERUB
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
This is also done in the webserver 1 and 2 as seen below.
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.
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.
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.
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
You can type "p" to view the partition table as shown below.
We use "w" to write the table and edit on the disk Type "w" and click enter Type "y" to proceed.
It states that the operation was successful.
Type lsblk command to check again and you will see that the xvdf file now has where the partition was created as seen below
Repeat the same steps and create the partition for " g and h " partitions and the results are shown below
Proceed to install the lvm2 package.
After that is successfully installed, we use the lsblk command to check our 3 partitions created
Create a physical volume using the pvcreate command for the xvdf1, xvdg1 and xvdh1 respectively
Use the lsblk command to check the 3 physical volumes created
Use the pvs command to check the 3 physical volumes.
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
Use "vgs" to check if it was implemented successfully.
The next step would be to create 3 logical volumes apps, logs and opt as shown below and confirm it was implemented successfully
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
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
And format the 3 logical volumes (command apps, logs and opt) with the mkfs command
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.
We would then mount the 3 logical volume path with the 3 mounting points as shown below
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
NFS server installation is completed, enabled and actively running.
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.
The ipv4 cidr is shown below
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
After permission was allowed. see below as permission has been granted to nobody as well as the chmod 777 permission.
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.
Paste the code below in /etc/exports, Save and quit to get back to the terminal
Verify they are properly mounted successfully with the command below.
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
Click security and security group
Add all rules.
Including the subnet cidr block of the webservers to access the NFS server.
Added successfully
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.
To access the MySQL environment, we use the command below
but when we exit it, we need to use this
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
To use and show all tables in the MySQL ,
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.
Now lets proceed by flushing the privileges and showing the database to see if we successfully created the databases.
Type: "Use tooling" to activate the database and show tables
The new user called web-access is shown below.
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
And install nfs-util
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.
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 .
Navigate back to NFS server. Change directory to /mnt and check its content. You will find the file test file there .
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 .
Proceed to install Apache and PHP from a third party Remi's repository is shown below
Install Apache
Installation continued and type y
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
You can still run the command without the: remi-7.4 to get the installation and click yes
Then we proceed to install the PHP and type y and click enter
We then proceed to start PHP and enable it and check the status to know if it is running . This can be seen below
Next is to set a Boolean and ensure that port 80 is opened.
Run the mount command and check the df -h command below
You can now start the httpd and check status as well.
Enable the httpd
We can check the webserver and copy the public Ip address.
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
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
We now proceed to create a fork repository to retrieve the source code from the git hub account.
First, install git on the webserver
Once installed then you clone the https repo.
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.
From the html directory change directory into /etc/httpd/conf.d and use the cat command to view the welcome.conf file.
We would now edit the functions.php file in the html folder.
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.
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
So, we proceed by writing the command
Check blkid to view the id .
Then we launch out ip addresses for the 2 servers and it is
successfully displayed
We would go further to type in the details for the username and password and they both are successfully logged
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💚👏