<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: tundek</title>
    <description>The latest articles on DEV Community by tundek (@afeez).</description>
    <link>https://dev.to/afeez</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1153790%2F533b723b-a449-4992-ba19-ca50ac4d36b7.png</url>
      <title>DEV Community: tundek</title>
      <link>https://dev.to/afeez</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/afeez"/>
    <language>en</language>
    <item>
      <title>Resolving SPF and MX records for rodamour.com</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Thu, 16 Jan 2025 10:27:01 +0000</pubDate>
      <link>https://dev.to/afeez/resolving-spf-and-mx-records-for-rodamourcom-5ho3</link>
      <guid>https://dev.to/afeez/resolving-spf-and-mx-records-for-rodamourcom-5ho3</guid>
      <description>&lt;p&gt;To resolve the SPF and MX record issues for your domain, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add an SPF Record
The Sender Policy Framework (SPF) is used to specify which mail servers are authorized to send emails on behalf of your domain.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;SPF Record Value Example:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;v=spf1 include:spf.protection.outlook.com -all&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Adjust the include: part depending on your email provider. For example:&lt;/p&gt;

&lt;p&gt;Google Workspace: &lt;code&gt;v=spf1 include:_spf.google.com -all&lt;/code&gt;&lt;br&gt;
Microsoft 365: v=spf1 include:spf.protection.outlook.com -all&lt;br&gt;
Custom Mail Server: Use your mail server's IP or domain.&lt;br&gt;
Steps to Add SPF Record:&lt;/p&gt;

&lt;p&gt;Log in to your DNS hosting provider.&lt;br&gt;
Add a new DNS record:&lt;br&gt;
Type: TXT&lt;br&gt;
Host/Name: @ (or your domain name, e.g., rodarmour.com)&lt;br&gt;
Value: The SPF record value provided above.&lt;br&gt;
Save the record and wait for DNS propagation (can take a few hours).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add an MX Record
MX (Mail Exchange) records specify the mail servers responsible for receiving emails for your domain.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;MX Record Value Example: If you're using Google Workspace:&lt;/p&gt;

&lt;p&gt;Priority: 1&lt;br&gt;
&lt;code&gt;Value: aspmx.l.google.com&lt;/code&gt;&lt;br&gt;
Additional Google Workspace records:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Priority: 5   Value: alt1.aspmx.l.google.com&lt;br&gt;
Priority: 5   Value: alt2.aspmx.l.google.com&lt;br&gt;
Priority: 10  Value: alt3.aspmx.l.google.com&lt;br&gt;
Priority: 10  Value: alt4.aspmx.l.google.com&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;If you're using Microsoft 365:&lt;/p&gt;

&lt;p&gt;Priority: 0&lt;br&gt;
Value: .mail.protection.outlook.com&lt;br&gt;
For custom servers, consult your email service provider for the correct MX records.&lt;/p&gt;

&lt;p&gt;Steps to Add MX Record:&lt;/p&gt;

&lt;p&gt;Log in to your DNS hosting provider.&lt;br&gt;
Add a new DNS record:&lt;br&gt;
Type: MX&lt;br&gt;
Host/Name: @ (or your domain name, e.g., rodarmour.com)&lt;br&gt;
Value: MX server address (e.g., aspmx.l.google.com for Google or yourdomain.mail.protection.outlook.com for Microsoft 365).&lt;br&gt;
Priority: Set as per the provider's recommendation (e.g., 1 or 0 for primary mail servers).&lt;br&gt;
Save the record and wait for DNS propagation.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Deploying any LAMP Stack Application with Advanced Bash Script</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Fri, 03 Jan 2025 09:48:31 +0000</pubDate>
      <link>https://dev.to/afeez/deploying-any-lamp-stack-application-with-advanced-bash-script-39gi</link>
      <guid>https://dev.to/afeez/deploying-any-lamp-stack-application-with-advanced-bash-script-39gi</guid>
      <description>&lt;p&gt;Hi Guyss!! Yeah i know i know i know, it's being a while i posted and you must be wondering where this guy was and surely missed my piece.&lt;/p&gt;

&lt;p&gt;Well i have been learning more to provide you with some advanced topics and i hope it helps. &lt;/p&gt;

&lt;p&gt;Today we will be delving into a topic we are familiar with but in a grand style, talking about automating any LAMP stack application however, we will be writing the script for each and every step without any manual input from your side.&lt;/p&gt;

&lt;p&gt;Let's get into it:&lt;/p&gt;

&lt;p&gt;There is a total of 4 major steps involved in installing and automating the LAMP stack App&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Deploying Pre-Requisites, Installing Firewalld
&lt;/h4&gt;

&lt;h4&gt;
  
  
  2. Deploying &amp;amp; Configure the Database, Installing MariaDB (You can use MySql, choice is yours)
&lt;/h4&gt;

&lt;h4&gt;
  
  
  3. Deploying &amp;amp; Configure the web server, Installing httpd,php, php-mysqlnd
&lt;/h4&gt;

&lt;h4&gt;
  
  
  4. Testing
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Let's explore the major steps and see how it works&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
#
# Automate ECommerce Application Deployment
# Author: Mumshad Mannambeth

#######################################
# Print a message in a given color.
# Arguments:
#   Color. eg: green, red
#######################################
function print_color(){
  NC='\033[0m' # No Color

  case $1 in
    "green") COLOR='\033[0;32m' ;;
    "red") COLOR='\033[0;31m' ;;
    "*") COLOR='\033[0m' ;;
  esac

  echo -e "${COLOR} $2 ${NC}"
}

#######################################
# Check the status of a given service. If not active exit script
# Arguments:
#   Service Name. eg: firewalld, mariadb
#######################################
function check_service_status(){
  service_is_active=$(sudo systemctl is-active $1)

  if [ $service_is_active = "active" ]
  then
    echo "$1 is active and running"
  else
    echo "$1 is not active/running"
    exit 1
  fi
}

#######################################
# Check the status of a firewalld rule. If not configured exit.
# Arguments:
#   Port Number. eg: 3306, 80
#######################################
function is_firewalld_rule_configured(){

  firewalld_ports=$(sudo firewall-cmd --list-all --zone=public | grep ports)

  if [[ $firewalld_ports == *$1* ]]
  then
    echo "FirewallD has port $1 configured"
  else
    echo "FirewallD port $1 is not configured"
    exit 1
  fi
}

#######################################
# Check if a given item is present in an output
# Arguments:
#   1 - Output
#   2 - Item
#######################################
function check_item(){
  if [[ $1 = *$2* ]]
  then
    print_color "green" "Item $2 is present on the web page"
  else
    print_color "red" "Item $2 is not present on the web page"
  fi
}



echo "---------------- Setup Database Server ------------------"

# Install and configure firewalld
print_color "green" "Installing FirewallD.. "
sudo yum install -y firewalld

print_color "green" "Installing FirewallD.. "
sudo systemctl start firewalld
sudo systemctl enable firewalld

# Check FirewallD Service is running
check_service_status firewalld

# Install and configure Maria-DB
print_color "green" "Installing MariaDB Server.."
sudo yum install -y mariadb-server

print_color "green" "Starting MariaDB Server.."
sudo systemctl start mariadb
sudo systemctl enable mariadb

# Check FirewallD Service is running
check_service_status mariadb

# Configure Firewall rules for Database
print_color "green" "Configuring FirewallD rules for database.."
sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp
sudo firewall-cmd --reload

is_firewalld_rule_configured 3306


# Configuring Database
print_color "green" "Setting up database.."
cat &amp;gt; setup-db.sql &amp;lt;&amp;lt;-EOF
  CREATE DATABASE ecomdb;
  CREATE USER 'ecomuser'@'localhost' IDENTIFIED BY 'ecompassword';
  GRANT ALL PRIVILEGES ON *.* TO 'ecomuser'@'localhost';
  FLUSH PRIVILEGES;
EOF

sudo mysql &amp;lt; setup-db.sql

# Loading inventory into Database
print_color "green" "Loading inventory data into database"
cat &amp;gt; db-load-script.sql &amp;lt;&amp;lt;-EOF
USE ecomdb;
CREATE TABLE products (id mediumint(8) unsigned NOT NULL auto_increment,Name varchar(255) default NULL,Price varchar(255) default NULL, ImageUrl varchar(255) default NULL,PRIMARY KEY (id)) AUTO_INCREMENT=1;

INSERT INTO products (Name,Price,ImageUrl) VALUES ("Laptop","100","c-1.png"),("Drone","200","c-2.png"),("VR","300","c-3.png"),("Tablet","50","c-5.png"),("Watch","90","c-6.png"),("Phone Covers","20","c-7.png"),("Phone","80","c-8.png"),("Laptop","150","c-4.png");

EOF

sudo mysql &amp;lt; db-load-script.sql

mysql_db_results=$(sudo mysql -e "use ecomdb; select * from products;")

if [[ $mysql_db_results == *Laptop* ]]
then
  print_color "green" "Inventory data loaded into MySQl"
else
  print_color "green" "Inventory data not loaded into MySQl"
  exit 1
fi


print_color "green" "---------------- Setup Database Server - Finished ------------------"

print_color "green" "---------------- Setup Web Server ------------------"

# Install web server packages
print_color "green" "Installing Web Server Packages .."
sudo yum install -y httpd php php-mysqlnd

# Configure firewalld rules
print_color "green" "Configuring FirewallD rules.."
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
sudo firewall-cmd --reload

is_firewalld_rule_configured 80

# Update index.php
sudo sed -i 's/index.html/index.php/g' /etc/httpd/conf/httpd.conf

# Start httpd service
print_color "green" "Start httpd service.."
sudo systemctl  start httpd
sudo systemctl enable httpd

# Check FirewallD Service is running
check_service_status httpd

# Download code
print_color "green" "Install GIT.."
sudo yum install -y git
sudo git clone https://github.com/kodekloudhub/learning-app-ecommerce.git /var/www/html/
sudo sed -i 's#// \(.*mysqli_connect.*\)#\1#' /var/www/html/index.php
sudo sed -i 's#// \(\$link = mysqli_connect(.*172\.20\.1\.101.*\)#\1#; s#^\(\s*\)\(\$link = mysqli_connect(\$dbHost, \$dbUser, \$dbPassword, \$dbName);\)#\1// \2#' /var/www/html/index.php

print_color "green" "Updating index.php.."
sudo sed -i 's/172.20.1.101/localhost/g' /var/www/html/index.php

print_color "green" "---------------- Setup Web Server - Finished ------------------"

# Test Script
web_page=$(curl http://localhost)

for item in Laptop Drone VR Watch Phone
do
  check_item "$web_page" $item
done

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the file with an extension &lt;code&gt;.sh&lt;/code&gt; i named it &lt;code&gt;deploy-ecom-app.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Try it out and lemme know if it works for you :) Thanks guys, see you on the next one. &lt;/p&gt;

</description>
      <category>devops</category>
      <category>linux</category>
      <category>programming</category>
      <category>centos</category>
    </item>
    <item>
      <title>Comming back to this project... Still on the foundamentals</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Wed, 01 Jan 2025 08:41:04 +0000</pubDate>
      <link>https://dev.to/afeez/comming-back-to-this-project-still-on-the-foundamentals-4db0</link>
      <guid>https://dev.to/afeez/comming-back-to-this-project-still-on-the-foundamentals-4db0</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/ssheffk" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F814772%2F56d600a0-425f-4459-9689-57b397212916.png" alt="ssheffk"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/ssheffk/learning-by-doing-building-an-incident-alert-system-4i2b" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;🚀 Learning by Doing: Building an Incident Alert System 🛠️&lt;/h2&gt;
      &lt;h3&gt;Serdar Shefketov ・ Dec 23 '24&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#go&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#kafka&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#microservices&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#kubernetes&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>learning</category>
    </item>
    <item>
      <title>Making docker available in Jenkins without a plugin. Part 1</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Sat, 24 Feb 2024 17:10:42 +0000</pubDate>
      <link>https://dev.to/afeez/making-docker-available-in-jenkins-without-a-plugin-part-1-7g4</link>
      <guid>https://dev.to/afeez/making-docker-available-in-jenkins-without-a-plugin-part-1-7g4</guid>
      <description>&lt;p&gt;In this article, you will be able to run all your favourite docker commands in the same container that has your jenkins running..&lt;/p&gt;

&lt;p&gt;If you already have Jenkins running in a container, we will stop the container and restart it with the following commands.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Check the status of the running container
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;docker ps&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffj00xghgab6n313s080m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffj00xghgab6n313s080m.png" alt="Docker ps command" width="800" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;run the command &lt;code&gt;docker stop 8cb594e942c2&lt;/code&gt; to stop the container. Once the container stops, we can now re-run our jenkins app with this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -p 8080:8080 -p 50000:50000 -d -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/usr/bin/docker jenkins:jenkins:lts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yeah, i know :), the command seems ambiguous, complex to understand and confusing, let's break it down.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;docker run: This is the command to create and start a new Docker container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;-p 8080:8080: This option maps port 8080 of the host to port 8080 of the container. Jenkins typically runs its web interface on port 8080, so this mapping allows you to access the Jenkins web interface through your host machine's port 8080.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;-p 50000:50000: This maps port 50000 of the host to port 50000 of the container. Jenkins uses this port for agent connections, allowing build agents to communicate with the Jenkins server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;-d: This option runs the container in detached mode, meaning the container runs in the background and does not block the terminal session.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;-v jenkins_home:/var/jenkins_home: This mounts a volume named jenkins_home to /var/jenkins_home inside the container. /var/jenkins_home is the default directory Jenkins uses to store its configuration and data. By mounting a volume, you ensure that this data persists across container restarts and recreations, maintaining your Jenkins state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;-v /var/run/docker.sock:/var/run/docker.sock: This volume mount is particularly interesting. It mounts the Docker socket from the host into the container. This allows the Jenkins container to communicate with the Docker daemon of the host machine, effectively allowing Jenkins to launch other Docker containers. This is often used for running Jenkins jobs inside separate Docker containers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;-v $(which docker):/usr/bin/docker: This mounts the Docker binary from the host into the container at /usr/bin/docker. This allows Jenkins running inside the container to execute Docker commands directly, assuming Docker is installed on the host at the path returned by $(which docker).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;jenkins:jenkins:lts: This specifies the Docker image to use. It seems like there's a repetition in the image name; typically, it would be something like jenkins/jenkins:lts where jenkins/jenkins is the Docker Hub repository for Jenkins images, and lts specifies that you want to use the Long-Term Support version of Jenkins.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Let's login into the Jenkins container
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it 8cb594e942c2 /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0jx5woti4csu0i8v74t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0jx5woti4csu0i8v74t.png" alt="Dokcer commands" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we try to execute the command &lt;code&gt;docker pull redis&lt;/code&gt; on the container, we will get an error which needs to be corrected so that we can successfully run docker commands on the container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06vthxdwgsgmlb245dny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06vthxdwgsgmlb245dny.png" alt="Docker" width="800" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Exit from the shell and login as root&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker exec -it -u 0 8cb594e942c2 /bin/bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;follow the above command with the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod 666 /var/run/docker.sock
ls -l /var/run/docker.sock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfnsdzrou9x8vo1v3aa3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnfnsdzrou9x8vo1v3aa3.png" alt="Docker" width="800" height="59"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the above, you are now able to execute docker commands on the jenkins execute shell.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Build a docker image for our App
&lt;/h3&gt;

&lt;p&gt;To build the docker image, we will now go into Jenkins and add the following command on the Execute shell part using the Dockerfile to build the image&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build -t java-maven-app:1.0 .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F22qpkqzbcevfzsj36thv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F22qpkqzbcevfzsj36thv.png" alt="Docker" width="800" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnptcgg211rvcte1kcvhg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnptcgg211rvcte1kcvhg.png" alt="Docker" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbd1ffj3qmsvdahrj536.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbd1ffj3qmsvdahrj536.png" alt="Dockerfile output" width="800" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Pushing the image to Artifactory (Docker Repository)
&lt;/h3&gt;

&lt;p&gt;We will now be pushing the image we have created into a private repository (docker repo) in this case.&lt;/p&gt;

&lt;p&gt;Some of the configurations we need to do on Jenkins include the following&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd969ok835r7jesuydg5k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd969ok835r7jesuydg5k.png" alt="Repository" width="800" height="458"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2aimbk827yiritu7ez0i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2aimbk827yiritu7ez0i.png" alt="Repo1" width="800" height="414"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwe0rdx1dcaqhaqraxuxt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwe0rdx1dcaqhaqraxuxt.png" alt="Repo2" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After a successful build on Jenkins we will have an output like so with a SUCCESS message&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jb3bdir4nauvml2eygj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jb3bdir4nauvml2eygj.png" alt="Build success" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the image will be pushed to the private repo&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1pny9pmjwltkk7zj392h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1pny9pmjwltkk7zj392h.png" alt="Private repo build" width="800" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>jenkins</category>
      <category>linux</category>
    </item>
    <item>
      <title>Setting up Ansible for Automating tasks</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Sat, 18 Nov 2023 06:19:07 +0000</pubDate>
      <link>https://dev.to/afeez/setting-up-ansible-for-automating-tasks-mdb</link>
      <guid>https://dev.to/afeez/setting-up-ansible-for-automating-tasks-mdb</guid>
      <description>&lt;h2&gt;
  
  
  Setting up Ansible
&lt;/h2&gt;

&lt;p&gt;Hey Fellas, in this article, we will be installing Ansible and creating a simple task of automation using Ansible and showing you all the processes involved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zi0u_Quc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jvhd3ynpxdx3vder9565.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zi0u_Quc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jvhd3ynpxdx3vder9565.png" alt="Ansible" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We need to create 3 Amazon EC2 instances, 1 will be the Master while the other 2 will be the targets.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After creating the Instances, we can name one of them Ansible_Master while the other two Ansible_Target1 and Ansible_Target2 to simulate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Install Ansible
&lt;/h3&gt;

&lt;p&gt;With the following command, we can install ansible&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo yum install ansible&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Create the ec2-key.pem file and paste your key into this file&lt;/p&gt;

&lt;p&gt;It should look something like this if you run the &lt;code&gt;cat ec2-file.pem&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yMLDhz5j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4gzrmoedtsvulsqpkqdj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yMLDhz5j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4gzrmoedtsvulsqpkqdj.png" alt="Key description" width="800" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run chmod on the key file to ensure it is not accessible to anyone and only the root user can read the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod 400 ec2-file.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The image below shows how to use Ansible to call different servers all at the same time&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HApNDWCs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e44sakhlz767n7yw0cu8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HApNDWCs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e44sakhlz767n7yw0cu8.png" alt="Asn" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create Inventory File
&lt;/h3&gt;

&lt;p&gt;Use the nano program to create the inventory.txt file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano inventory.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible-target-1 ansible_host=16.170.230.179 ansible_connection=ssh ansible_user=ec2-user
ansible-target-2 ansible_host=51.20.116.72 ansible_connection=ssh ansible_user=ec2-user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Escape and save the file. To run the file, we can use the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible ansible-target-1 -m ping -i inventory.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We should get this error and i will explain in a sec why that is&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Oh_35znL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53sufzorvap2oonmsgfu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Oh_35znL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53sufzorvap2oonmsgfu.png" alt="Ansible Error" width="800" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the inventory.txt file the mode of connection we used is SSH and we need the SSH key for the servers we are trying to connect to, that is why we are receiving this error resposne from the server.&lt;/p&gt;

&lt;p&gt;We need to assign the SSH key we copied at the beginning when installing our instances to the ssh-agent using the command below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-agent bash
cp ec2-key.pem ~/.ssh/
ssh-add ~/.ssh/ec2-key.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o30FG68d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3f1myr8g140pd21rogrt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o30FG68d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3f1myr8g140pd21rogrt.png" alt="Ansible" width="800" height="105"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Running this command again&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible ansible-target-1 -m ping -i inventory.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KGvv1aui--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2vcpev6b52v9yeepjlwj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KGvv1aui--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2vcpev6b52v9yeepjlwj.png" alt="Ansible1" width="800" height="169"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible ansible-target-2 -m ping -i inventory.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U9iG_i1Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zlf1dl172a98smug4nl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U9iG_i1Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zlf1dl172a98smug4nl.png" alt="Ansible2" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To ensure that we can connect to our servers (instances) at all times, we need to configure the ansible configuration file to allow us to do that without interruption.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XKaEselC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hwvrrx8wqb6h9atxbpgh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XKaEselC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hwvrrx8wqb6h9atxbpgh.png" alt="Ansile1-2" width="800" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the ansible config file does not exist in the &lt;code&gt;/etc/ansible/ansible.cfg&lt;/code&gt; we can create it by running the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible-config init --disabled -f ini &amp;gt; /tmp/ansible.cfg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The config file will be sent to the &lt;code&gt;/tmp/ansible.cfg&lt;/code&gt; (tmp folder) and then it can be moved to the main folder /etc/ansible&lt;/p&gt;

&lt;p&gt;As a refresher, we can use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo cp /tmp/ansible.cfg /etc/ansible
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to copy the ansible config file into the main directory where it can be read.&lt;/p&gt;

&lt;p&gt;Let's now try the command once again for both targets&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible ansible-target-1 -m ping -i inventory.txt 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible ansible-target-2 -m ping -i inventory.txt 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assuming we are having a hundred or more targets, do we keep changing the targets number using the above command? NO&lt;/p&gt;

&lt;p&gt;Here is a better way to ensure we can communicate to all the targets at once:&lt;/p&gt;

&lt;p&gt;Let's add a tag-name &lt;code&gt;servers&lt;/code&gt; to the inventory.txt file we created earlier. &lt;/p&gt;

&lt;p&gt;Your inventory.txt file should now look like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oxMhLhYT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vxhlzkzd3odhol3to3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oxMhLhYT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5vxhlzkzd3odhol3to3w.png" alt="Inventory file updated" width="800" height="78"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run this command to see the magic all targets can now be connected to at the same time with a single command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ansible servers -m ping -i inventory.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rPtKuZ3S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2lrmdimjkxp2ng0nb9yc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rPtKuZ3S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2lrmdimjkxp2ng0nb9yc.png" alt="Ansible description" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ansible</category>
      <category>automation</category>
      <category>learning</category>
      <category>linux</category>
    </item>
    <item>
      <title>IMPLEMENTATION OF the LEMP STACK on AWS</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Sun, 01 Oct 2023 14:40:23 +0000</pubDate>
      <link>https://dev.to/afeez/implementation-of-the-lemp-stack-on-aws-2loc</link>
      <guid>https://dev.to/afeez/implementation-of-the-lemp-stack-on-aws-2loc</guid>
      <description>&lt;h1&gt;
  
  
  WEBSTACK: IMPLEMENTATION OF the LEMP STACK on AWS
&lt;/h1&gt;

&lt;p&gt;The LEMP stack is a collection of open source and free software bundles which web developers around the world use to write software of different types and application. Where the accronym L stands for the Linux operating system, E is the Nginx server the most popular server software, M stands for MYSQL (Also one of the most popular Database server) and P for PHP backend programming languauge.&lt;/p&gt;

&lt;p&gt;Pre-requisites for Installing Nginx server.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 0:
&lt;/h4&gt;

&lt;p&gt;For this project, it is better to use a differnet AWS instance. Kindly create a new one, which by now you already know how todo.&lt;br&gt;
Once it has been installed and .pem key download, navigate into the directory housing the key and SSH into the server.&lt;br&gt;
Also please make sure you have port 80 active on the instance for this project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage4.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing Nginx Web Server
&lt;/h2&gt;
&lt;h3&gt;
  
  
  update a list of packages in package manager and install nginx
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
sudo apt install nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;Command output&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage1.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To verify and test that Nginx has been successfully installed and working, copy and paste the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Command output&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us check how we can access our server locally on our Ubuntu shell using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl localhost:80 
curl http://127.0.0.1:80
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can now check the result on our browser and see if the server displays th following information, if it does, then Nginx worked using the http://:80 &lt;br&gt;
replacing the  with the IP address from your provider in this case AWS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage6.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can get your public address information on the AWS panel or use the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s http://169.254.169.254/latest/meta-data/public-ipv4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Command output&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage7.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing MySQL
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 2: Installing MySQL on the server
&lt;/h3&gt;

&lt;p&gt;We now have a Webserver, but for a complete application, we also need to store information and data, so we need a DataBase Management System (DBMS) to help with this, in this case MySQL&lt;/p&gt;

&lt;p&gt;Let's install MySQL on our server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install mysql-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the command below to log into the Database Admnistation as user root. Right now our Database is not secure and anyone can have access by just typing the command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage6_2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage6_2.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us firstly secure the Database by running the secure default script to lock anyone that tries to have access with the command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PassWord.1';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage7_2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage7_2.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you try to login now, except as root. It is time to start the interactive script for securing the DB.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql_secure_installation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage9.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage8.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing PHP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 3: Installing PHP on the server
&lt;/h3&gt;

&lt;p&gt;We now have Nginx and MySQL installed on our server. But we still need a server side language to complete the STACK, since we want a LEMP STACK application it will be imcomplete without the server side programming Language in this case PHP&lt;/p&gt;

&lt;p&gt;Let's install PHP now. Paste the command below on your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install php-fpm php-mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage10.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the command php -v to check the version of PHP installed or if PHP is already installed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage11.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, our LEMP STACK has now been completed, Linux, Nginx, MySQL, PHP (LEMP)&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Nginx to use PHP Processor
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 4: Configuring Nginx to use PHP Processor on the server
&lt;/h3&gt;

&lt;p&gt;Similar to Apache's virtual host (Refresher: Allows you host more than one website on the server), Nginx has a server block(s) that encapsulate configuration details allowing you to host multiple website on a single server.&lt;/p&gt;

&lt;p&gt;Nginx has one server block by default and servers the default directory /var/www/html. This works well for a single website, however for multiple websites, we might need to make use of the /sites-available diretory similar to that of Apache.&lt;/p&gt;

&lt;p&gt;We need to create a directory in the /var/www folder and do the configuration settings.&lt;/p&gt;

&lt;p&gt;Let's create a new project "projectLEMP" in the /www/ folder&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir /var/www/projectLEMP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We will now assign the ownership of the directory with the $USER environment variable to the current user&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chown -R $USER:$USER /var/www/projectLEMP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next is to open a new configuration file in the &lt;code&gt;sites-available&lt;/code&gt; directory of the&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo vi /etc/nginx/sites-available/projectLEMP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then copy and paste the following in the open file above and save the file when done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#/etc/nginx/sites-available/projectLEMP

server {
    listen 80;
    server_name projectLEMP www.projectLEMP;
    root /var/www/projectLEMP;

    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
     }

    location ~ /\.ht {
        deny all;
    }

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's take out time to understand what each of the lines above mean&lt;/p&gt;

&lt;p&gt;listen: This tells the server what port to listen on, port 80 which is the default for HTTP&lt;/p&gt;

&lt;p&gt;root: This defines the default document root that contains all the website files&lt;/p&gt;

&lt;p&gt;index: Defines the order in which Nginx will priortize the index files. Common practise ensure index.html has more precedence than index.php file&lt;/p&gt;

&lt;p&gt;servername: Indicates which domain name and/ IP address the server block should point to&lt;/p&gt;

&lt;p&gt;location / : The first location block includes a &lt;code&gt;try_files&lt;/code&gt; directives and then it checks for existence of files or directories matching the URI request. If Nginx doesn't find the files it returns a 404 error&lt;/p&gt;

&lt;p&gt;location ~ .php$ : The location block does the actual PHP processing by pointing Nginx to the fastcgi-php.conf configuration file, and the php8.1-fpm.sock file which declares what sock is associated with the php-fpm&lt;/p&gt;

&lt;p&gt;location ~ /.ht : This location is the last one that deals with the .htaccess file which Nginx does not process.&lt;br&gt;
By adding the &lt;code&gt;deny all&lt;/code&gt; if any .htaccess file finds it's way &lt;/p&gt;

&lt;p&gt;Let's activate the configuration we just did by linking the config file from Nginx's &lt;code&gt;sites-enabled&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ln -s /etc/nginx/sites-available/projectLEMP /etc/nginx/sites-enabled/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage12.png" alt="Output"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage13.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above comand tells Nginx to use the projectLEMP config file when next it is loading.&lt;/p&gt;

&lt;p&gt;Checking to see if there are any errors&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nginx -t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage14.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage14.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above output result shows that the configuration is fine and good to go.&lt;/p&gt;

&lt;p&gt;Next is to disable the default Nginx config file currently listening on port 80, to do this, run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo unlink /etc/nginx/sites-enabled/default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's reload nginx for the changes to take effect&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl reload nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can run this code to create a sample index.html file which displays the hostname and public IP address of the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo echo 'Hello LEMP from hostname' $(curl -s http://169.254.169.254/latest/meta-data/public-hostname) 'with public IP' $(curl -s http://169.254.169.254/latest/meta-data/public-ipv4) &amp;gt; /var/www/projectLEMP/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage15.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing PHP with Nginx
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 5: Testing PHP with the Nginx server
&lt;/h3&gt;

&lt;p&gt;We will be writing a very basic php information file. Use the &lt;code&gt;nano /var/www/projectLEMP/info.php&lt;/code&gt; and paste the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
phpinfo();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage16.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Always ensure you remove the php info file from the server using &lt;code&gt;sudo rm /var/www/projectLEMP/info.php&lt;/code&gt; command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retrieving data from MySQL database
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 6: Writing code to retrieve data from the MySQL DB
&lt;/h3&gt;

&lt;p&gt;Let us create a simple todo list application, first the database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, create a database using the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create database TODO;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;show databases;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage17.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage17.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next is to create a user that will have access or priviledges to the database we just created. We are defining the user 'afeez_user' and password -&amp;gt; 'Password1' using this command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE USER 'afeez_user'@'%' IDENTIFIED WITH mysql_native_password BY 'PassWord.1';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this, let's grant permission to the user afeez_user to&lt;/p&gt;

&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage18.png" alt="Output"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GRANT ALL ON TODO.* TO 'afeez_user'@'%';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will allow 'afeez_user' full priviledge to work on the TODO database while preventing the user from modifying or creating other databases on the server.&lt;/p&gt;

&lt;p&gt;Login with the code &lt;code&gt;sudo mysql -u afeez_user -p&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE TODO.todo_list (item_id INT AUTO_INCREMENT,content VARCHAR(255),PRIMARY KEY(item_id));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding some sample data into the table todo_list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INSERT INTO TODO.todo_list (content) VALUES ("My first important item");
INSERT INTO TODO.todo_list (content) VALUES ("My second important item");
INSERT INTO TODO.todo_list (content) VALUES ("My third important item");
INSERT INTO TODO.todo_list (content) VALUES ("One more important item");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT * FROM TODO.todo_list; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage18.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is time to now create a file a php file to access the databse we just created and pull the record to be displayed on the browser.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
$user = "afeez_user";
$password = "PassWord.1";
$database = "TODO";
$table = "todo_list";

try {
  $db = new PDO("mysql:host=localhost;dbname=$database", $user, $password);
  echo "&amp;lt;h2&amp;gt;TODO&amp;lt;/h2&amp;gt;&amp;lt;ol&amp;gt;";
  foreach($db-&amp;gt;query("SELECT content FROM $table") as $row) {
    echo "&amp;lt;li&amp;gt;" . $row['content'] . "&amp;lt;/li&amp;gt;";
  }
  echo "&amp;lt;/ol&amp;gt;";
} catch (PDOException $e) {
    print "Error!: " . $e-&amp;gt;getMessage() . "&amp;lt;br/&amp;gt;";
    die();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/images%2Fimage19.png" alt="Output"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Installing Webstack, LAMP(Linux, Apache, MySQL and PHP) on AWS instance</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Wed, 27 Sep 2023 13:36:03 +0000</pubDate>
      <link>https://dev.to/afeez/installing-webstack-lamplinux-apache-mysql-and-php-on-aws-instance-2kek</link>
      <guid>https://dev.to/afeez/installing-webstack-lamplinux-apache-mysql-and-php-on-aws-instance-2kek</guid>
      <description>&lt;h1&gt;
  
  
  WEBSTACK: IMPLEMENTATION OF the LAMP STACK on AWS
&lt;/h1&gt;

&lt;p&gt;The LAMP stack is a collection of open source and free software bundles which by web developers around the world use to write software of different types and application. Where the accronym L stands for the Linux operating system, A is the Apache server the most popular server software, M stands for MYSQL (Also one of the most popular Database server) and P for PHP backend programming languauge.&lt;/p&gt;

&lt;p&gt;Pre-requisites for Installing Apache server.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 0:
&lt;/h4&gt;

&lt;p&gt;Installed an E2C instance and SSH into the server&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Apache and Updating the Firewall
&lt;/h2&gt;

&lt;p&gt;Apache HTTP Server is one of the most used servers in the world. More than 60% of the world's server is Apache. Most especially web developers use this server because it is simple to setup and open source. Ther are other servers which are also in use like IIS by Microsoft, Nginx &lt;/p&gt;

&lt;p&gt;Use the code below to install Apache on your AWS instance&lt;/p&gt;

&lt;h1&gt;
  
  
  update a list of packages in package manager
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Command output&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rcFymHt1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rcFymHt1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image1.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rcFymHt1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rcFymHt1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image1.png" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Installing Apache server
&lt;/h3&gt;

&lt;h1&gt;
  
  
  run apache2 package installation
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GCwcMkhV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GCwcMkhV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image2.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run the command below to verify that Apache is running fine&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iPfmLVNg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iPfmLVNg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image3.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The status indicates Active: running =&amp;gt; showing that the apache server is now running, and we can test with the following commands which will dipsplay the content of the server file&lt;/p&gt;

&lt;p&gt;Use the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl http://localhost:80 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl http://127.0.0.1:80 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;localhost:80 indicates that we are calling the local DNS server to to display the content of the server, while 127.0.0.1:80 is using the IP address of the server to check the details of the server.&lt;br&gt;
We are using port 80, which is HTTP for web servers&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Checking if Apache Server is working using our IPv4 (from AWS instance) on the browser
&lt;/h3&gt;

&lt;p&gt;Visit your browser and type:&lt;br&gt;
http://:80&lt;/p&gt;
&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--odIUO5A1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--odIUO5A1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image4.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the curl command below to check your Public IP address without going to the AWS console&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s http://169.254.169.254/latest/meta-data/public-ipv4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IORd3AIW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IORd3AIW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image5.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing MySQL
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 2: Installing MySQL on the server
&lt;/h3&gt;

&lt;p&gt;We now have a Webserver, but for a complete application, we also need to store information and data, so we need a DataBase Management System (DBMS) to help with this, in this case MySQL&lt;/p&gt;

&lt;p&gt;Let's install MySQL on our server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install mysql-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use the command below to log into the Database Admnistation as user root. Right now our Database is not secure and anyone can have access by just typing the command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F8Rusfx6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F8Rusfx6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image6.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us firstly secure the Database by running the secure default script to lock anyone that tries to have access with the command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PassWord.1';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D06dn9Yl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D06dn9Yl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image7.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you try to login now, except as root. It is time to start the interactive script for securing the DB.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mysql_secure_installation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7vyFlwxS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7vyFlwxS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image9.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ySwCFb7r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ySwCFb7r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image8.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing PHP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 3: Installing PHP on the server
&lt;/h3&gt;

&lt;p&gt;We now have Apache and MySQL installed on our server. But we still need a server side language to complete the STACK, since we want a LAMP STACK application it will be imcomplete without the server side programming Language in this case PHP&lt;/p&gt;

&lt;p&gt;Let's install PHP now. Paste the command below on your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install php libapache2-mod-php php-mysql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lBKxgudm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lBKxgudm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image10.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--he2V_ifF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image11.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--he2V_ifF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image11.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the command php -v to check the version of PHP installed or if PHP is already installed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SsjmNTk5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SsjmNTk5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image12.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, our LAMP STACK has now been completed, Linux, Apache, MySQL, PHP (LAMP)&lt;/p&gt;

&lt;h3&gt;
  
  
  NOTE: You can check the configuration of VirtualHost (VHosts) on the server. ==&amp;gt; &lt;a href="https://httpd.apache.org/docs/2.4/vhosts/"&gt;VIRTUAL HOST&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Also use TO check the configuration of your server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apachectl -S
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Creating a virtual Host for your Website Using Apache
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Step 4: Creating a Virtual Host (VHost) using Apache Server fro hosting your website
&lt;/h3&gt;

&lt;p&gt;In this project we will be using a domain name called projectlamp, but ofcourse you can have anyname of your choice.&lt;/p&gt;

&lt;p&gt;By default document root that serve the website are on the directory &lt;strong&gt;/var/www/html&lt;/strong&gt; which comes with apache on Ubuntu 2X.X.X &lt;/p&gt;

&lt;p&gt;Let us create our project folder using the project name by navigating into the folder &lt;strong&gt;/var/www/&lt;/strong&gt; and create &lt;strong&gt;projectlamb&lt;/strong&gt; directory&lt;/p&gt;

&lt;p&gt;or we can use the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mkdir /var/www/projectlamp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also use the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo chown -R $USER:$USER /var/www/projectlamp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to assign ownership of the folder to the current user. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's open and create a new configuration file for the &lt;code&gt;sites-available&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo vi /etc/apache2/sites-available/projectlamp.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will open and create an empty file projectlamp.conf which will host the info below&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;use the &lt;code&gt;i&lt;/code&gt; insert mode, then paste the code below&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And add the following line of code in the &lt;code&gt;projectlamp.conf&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;VirtualHost *:80&amp;gt;
    ServerName projectlamp
    ServerAlias www.projectlamp 
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/projectlamp
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
&amp;lt;/VirtualHost&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then &lt;code&gt;:wq!&lt;/code&gt; then press enter to save&lt;/p&gt;

&lt;p&gt;Let us check the content of the &lt;code&gt;sites-available&lt;/code&gt; directory the directory should now have the projectlamp.conf &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dcds0DzN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dcds0DzN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image13.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Summary: With the above Virtual Host Config, we are now saying Apache should server projectlamp using the /var/www/projectlamp as it's root directory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;You can comment out the first 2 lines (ServerName &amp;amp; Server Alias)&lt;/em&gt; if you don't want to use domain name to access the server using the # symbol.&lt;/p&gt;

&lt;p&gt;Let's now enable the new virtual host by running the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo a2ensite projectlamp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Fun fact, i think the meaning of a2ensite could be "Apache2 enable Site (a2ensite)" | Or what do you think?, that makes sense to me&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Anyway, remember we checked the content of the sites-available directory we saw a file name 000-default.conf, we need to disable this file because it is responsible for displaying the default files that comes pre-installed on Apache2.&lt;/p&gt;

&lt;p&gt;Use the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo a2dissite 000-default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need to run the command to ensure there are no config issues if we get the result &lt;code&gt;Syntax OK&lt;/code&gt; then everything looks good.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apache2ctl configtest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, let's reload the apache server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl reload apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Enable PHP on the Website
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 5: Enabling PHP on the website
&lt;/h3&gt;

&lt;p&gt;Apache by default looks for the index.html file on the server called Directoryindex, this is the file that get called/executed when the directory is called to server the pages hosted in it.&lt;/p&gt;

&lt;p&gt;Even though we might have an index.php file, the index.html will get called first by default, which can be used during maintainance mode to inform the users what is going on.&lt;/p&gt;

&lt;p&gt;To change the defualt behaviour of the Directoryindex, we need to edit the file /etc/apache2/mods-enabled/dir.conf&lt;/p&gt;

&lt;p&gt;run the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo vim /etc/apache2/mods-enabled/dir.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;IfModule mod_dir.c&amp;gt;
        DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
&amp;lt;/IfModule&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dcds0DzN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dcds0DzN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image13.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After editing the file, you can save &amp;amp; close the file then restart apache server to effect changes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl reload apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo echo 'Hello LAMP from hostname' $(curl -s http://169.254.169.254/latest/meta-data/public-hostname) 'with public IP' $(curl -s http://169.254.169.254/latest/meta-data/public-ipv4) &amp;gt; /var/www/projectlamp/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can use the above code to create an index.html file in teh /var/www/projectlamp directory to test our server.&lt;/p&gt;

&lt;h5&gt;
  
  
  Output
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M3uCz7n6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image14.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M3uCz7n6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/images/image14.png" alt="Output" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And BOOM!!! Congratulatios, We have our first website hosted on AWS &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Introduction to GIT and GitHUB</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Thu, 21 Sep 2023 19:01:21 +0000</pubDate>
      <link>https://dev.to/afeez/introduction-to-git-and-github-fo2</link>
      <guid>https://dev.to/afeez/introduction-to-git-and-github-fo2</guid>
      <description>&lt;h1&gt;
  
  
  Initializing a Repository and Making Commits
&lt;/h1&gt;

&lt;p&gt;First off, when you are trying to make use of git, there are some general setup that needs to be cleared off before we start using git on our working environment.&lt;/p&gt;

&lt;p&gt;But before then, we should have git installed on our PCs&lt;/p&gt;

&lt;p&gt;After installation of git, then we can use this setting to setup our git configuration&lt;/p&gt;

&lt;p&gt;First thing, we initialize git on our working directory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Code Output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tfi_1mH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/6c5887c9-8e23-46a3-b1af-b490b7971056" class="article-body-image-wrapper"&gt;&lt;img alt="image1" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tfi_1mH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/6c5887c9-8e23-46a3-b1af-b490b7971056" width="800" height="35"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we can go ahead with our setup. You can change the information as required to your details&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    git config --global user.name "Afeez"
    git config --global user.email "tundek79@gmail.com"
    git config --global init.defaultBranch main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a username&lt;/li&gt;
&lt;li&gt;Create an email for the account&lt;/li&gt;
&lt;li&gt;create a default branch called main&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Making commits
&lt;/h3&gt;

&lt;p&gt;First, we need to track our working files by adding the files into the staging area before comming them.&lt;/p&gt;

&lt;p&gt;There are 3 different stages where files are in the GIT lifecycle&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Working files (These are the files that you are currently working on and has not been tracked by GIT)&lt;/li&gt;
&lt;li&gt;Staging (At this stage, the files are already been tracked by GIT but has not been saved)&lt;/li&gt;
&lt;li&gt;Commit (At this point the files are now saved into the history books (if you will))&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Here's the demonstration for the above
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZNK3R61k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/191a6e74-c50a-4f1f-8c1b-6fcd8fe24fcc" class="article-body-image-wrapper"&gt;&lt;img alt="image2" src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZNK3R61k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/191a6e74-c50a-4f1f-8c1b-6fcd8fe24fcc" width="800" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the above image, i used the &lt;code&gt;git status&lt;/code&gt; to check the current status of my files on GIT and it indicates that none of the files are being tracked since i initialized git on the working folder.&lt;/p&gt;

&lt;p&gt;This id also indicated with the red color of al files that are yet to be tracked.&lt;/p&gt;

&lt;p&gt;I ran another command &lt;code&gt;git add .&lt;/code&gt; command to start tracking all the files in the directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fCcgZY9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/22366269-bb23-4248-aa83-270218576c84" class="article-body-image-wrapper"&gt;&lt;img alt="image3" src="https://res.cloudinary.com/practicaldev/image/fetch/s--fCcgZY9i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/22366269-bb23-4248-aa83-270218576c84" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After running the &lt;code&gt;git add&lt;/code&gt; command followed by the git status, the above is the result, showing a green color of all the working files indicating the files are now being tracked and once work is done, can be commited.&lt;/p&gt;

&lt;p&gt;Let's commit the changes into the history books using the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "first commit"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Code Output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CVy8eggB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/231b190a-4c6d-424e-8df8-dd1e4e141e77" class="article-body-image-wrapper"&gt;&lt;img alt="image4" src="https://res.cloudinary.com/practicaldev/image/fetch/s--CVy8eggB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/231b190a-4c6d-424e-8df8-dd1e4e141e77" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Working with Branches
&lt;/h1&gt;

&lt;p&gt;It's good that we now able to make commits and save into the history book which doesn't really go away unless maybe you or someone else tear (delete) the history book, but not sure anyone will do that nowadays.&lt;/p&gt;

&lt;p&gt;Anyway, let's say we have a project already in production and our customers are enjoying, but we need to add a new feature or work on an existing feature. How do we go about this without running into issues with our customers complaining they are unabel to use our softwares.&lt;/p&gt;

&lt;p&gt;A concept of branches came onboard, where by we create an exact copy of our project and we can make edits as required. It might be working on a new or existing feature. After working, testing and making sure all is fine with our new version, then we merge to the main branch. Enough talking, let's get working&lt;/p&gt;

&lt;h4&gt;
  
  
  Creating a new branch
&lt;/h4&gt;

&lt;p&gt;With what i have seen (abi), there seems to be a number of ways to creating a new branch. Let's explore some of them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch my_new_branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above creates a new branch but doesn't login to it&lt;/p&gt;

&lt;p&gt;To create and switch into a new branch, use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git switch -c another_branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Code output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o4ia9-qx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/04266c4d-d334-4fbc-8ac7-243dcf7381c1" class="article-body-image-wrapper"&gt;&lt;img alt="image5" src="https://res.cloudinary.com/practicaldev/image/fetch/s--o4ia9-qx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/04266c4d-d334-4fbc-8ac7-243dcf7381c1" width="800" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3nmD9Wu8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/c0b996d7-3126-4abc-bac1-4cff5ffae8a4" class="article-body-image-wrapper"&gt;&lt;img alt="image6" src="https://res.cloudinary.com/practicaldev/image/fetch/s--3nmD9Wu8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/c0b996d7-3126-4abc-bac1-4cff5ffae8a4" width="800" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Another method of creating branch, using the checkout command and listing the branch
&lt;/h6&gt;

&lt;p&gt;Use can also the use the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b newest_branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
`&lt;br&gt;
to check the list of all available branches&lt;/p&gt;

&lt;h4&gt;
  
  
  Code output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YdERKzgw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/5ff4e6ba-eb08-4c12-a8f2-455450f3fb2f" class="article-body-image-wrapper"&gt;&lt;img alt="image7" src="https://res.cloudinary.com/practicaldev/image/fetch/s--YdERKzgw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/5ff4e6ba-eb08-4c12-a8f2-455450f3fb2f" width="800" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Change into an Old branch
&lt;/h3&gt;

&lt;p&gt;To change your current branch into an old one, use the command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git checkout &amp;lt;branch-name&amp;gt;&lt;/code&gt; OR &lt;code&gt;git swith &amp;lt;branch-name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;h4&gt;
  
  
  Code output
&lt;/h4&gt;

&lt;p&gt;Switch =&amp;gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZSXHXZJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/1c6ec98f-d43e-43ec-ba90-d8f6f9b273a1" class="article-body-image-wrapper"&gt;&lt;img alt="image8" src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZSXHXZJ5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/1c6ec98f-d43e-43ec-ba90-d8f6f9b273a1" width="800" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Checkout =&amp;gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L_Cr_N8N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/e240c843-5a62-4c8c-ac01-950afb45ddb0" class="article-body-image-wrapper"&gt;&lt;img alt="image9" src="https://res.cloudinary.com/practicaldev/image/fetch/s--L_Cr_N8N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/e240c843-5a62-4c8c-ac01-950afb45ddb0" width="800" height="255"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Mergin a Branch into another Branch
&lt;/h3&gt;

&lt;p&gt;Let's switch into a new branch and make some changes on the new branch we switch to. Then exit into the main branch and see if the changes effect on the main branch&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
git switch new-branch&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Make some edits on the new branch, commit the changes and switch back into the main branch then run the following commands&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
git merge -m "Merging sample file, into the main branch" new-branch&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Code output
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--09SVa-1y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/bed6412d-af7b-408d-9e77-30127de999cf" class="article-body-image-wrapper"&gt;&lt;img alt="image10" src="https://res.cloudinary.com/practicaldev/image/fetch/s--09SVa-1y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/bed6412d-af7b-408d-9e77-30127de999cf" width="800" height="791"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Collaboration and Remote Repositories
&lt;/h1&gt;

&lt;p&gt;We have been working on our local computer or local server all these while, when we want to collaborate with other developers or team mates, they might not have access to our local computer, which is why it is important to work remotely and collaborate from their. &lt;/p&gt;

&lt;p&gt;For Creating Remote repositories, we will be using GitHub as a Social Coding platform where repositories can be created, worked on.&lt;/p&gt;

&lt;p&gt;The account creation for github should be fairly simple to do, visit the &lt;a href="https://github.com"&gt;GitHub Website&lt;/a&gt;&lt;br&gt;
After that, create a repository where all your files will be hosted and let's connect to the repo and upload all the work we have done so that we can collaborate with our workmates.&lt;/p&gt;

&lt;p&gt;&lt;a href="/Users/appple/Documents/DevOps_Projects/DevOps/Project1/images/image11.png" class="article-body-image-wrapper"&gt;&lt;img alt="Git init" src="/Users/appple/Documents/DevOps_Projects/DevOps/Project1/images/image11.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First off, we need to add a remote reporsitory to the local repo we have been working on, use the command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
git remote add origin https://github.com/tundek/DevOps.git&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Afterwards, it is time to push all your files to the remote repository using the command&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push origin &amp;lt;branch-name&amp;gt;&lt;/code&gt; =&amp;gt; &lt;code&gt;git push origin main&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t7sBwhfj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/f7364c92-38ce-4a8c-9c89-637435e35a84" class="article-body-image-wrapper"&gt;&lt;img alt="Screenshot 2023-09-16 at 18 17 59" src="https://res.cloudinary.com/practicaldev/image/fetch/s--t7sBwhfj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://github.com/tundek/DevOps/assets/15998669/f7364c92-38ce-4a8c-9c89-637435e35a84" width="800" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Branch Management and Tagging
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Introduction to Markdown Syntax
&lt;/h2&gt;

</description>
    </item>
    <item>
      <title>Sys Admin: How to configure sudoers file, Admin privileges.</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Sun, 10 Sep 2023 16:35:09 +0000</pubDate>
      <link>https://dev.to/afeez/sys-admin-how-to-configure-sudoers-file-admin-privileges-2ija</link>
      <guid>https://dev.to/afeez/sys-admin-how-to-configure-sudoers-file-admin-privileges-2ija</guid>
      <description>&lt;p&gt;Hi guys, hope you are doing are doing well. I'm excited to share another piece of informative writeup today.&lt;/p&gt;

&lt;p&gt;In this article I will be showing you some basic but useful configurations commands which includes configuring the sudoers file, admin rights, group right etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring the Sudoers file
&lt;/h3&gt;

&lt;p&gt;Have you seen this error message before when trying to run a sudo command even if you installed the linux O.S yourself on your PC or when you install Linux on VM machines.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sLCSmdFS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frdjpsx7usllx5kcj7ac.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sLCSmdFS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frdjpsx7usllx5kcj7ac.png" alt="Image" width="800" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The above image is showing us that the user "afeez" cannot use the sudo command&lt;/em&gt; which mean user afeez cannot perform elevated tasks using sudo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do we fix this?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are numerous ways of fixing this issue. But we will go with the most common solution, that is we can &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add the user into the sudoers file with all Admin privileges.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But there is a problem with this solution...&lt;/p&gt;

&lt;p&gt;Let's say we have about 10 new users that needs to have an admin privilege, that means we have to keep doing this. Editing the sudoers file for every user. Which will definitely waste our time and above all, not smart at all.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create groups and add each user(s) with the similar tasks to the same group. Sounds smart enough??&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Lemme show you how to do this.&lt;/p&gt;

&lt;p&gt;Let us create a group called devZ, we will give it all the access we require to run sudo then add user afeez to the group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo groupadd devZ
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yeah, you guessed it. It throws an error, because we still need sudo to create a new user.&lt;/p&gt;

&lt;p&gt;So, the workaround is to enter the command &lt;/p&gt;

&lt;p&gt;&lt;code&gt;su&lt;/code&gt; (su = switch user  =&amp;gt; $ )you will see the $ prompt once you have gained that access.&lt;/p&gt;

&lt;p&gt;followed by your password then we can continue with our solution. Just wanted to throw that in, incase you encounter such issue. You are welcome :) &lt;/p&gt;

&lt;p&gt;then run the &lt;code&gt;groupadd&lt;/code&gt; command to create a group and add the user afeez to be a part of the group.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo usermod -a -G genZ afeez
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will add user afeez into the genZ group&lt;/p&gt;

&lt;p&gt;You can confirm this by running the command &lt;code&gt;id afeez&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WHQxEQLc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/af9p0b3vq0kd7x4xboa7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WHQxEQLc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/af9p0b3vq0kd7x4xboa7.png" alt="Group" width="800" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LGx9B7Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/842bnf2iv13wbh6sjt92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LGx9B7Rl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/842bnf2iv13wbh6sjt92.png" alt="group" width="800" height="59"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2:
&lt;/h3&gt;

&lt;p&gt;Let's now edit the sudoers file.&lt;/p&gt;

&lt;p&gt;All configuration files can be found in the /etc/ folder, the sudoers file is in the /etc/sudoers&lt;/p&gt;

&lt;p&gt;Use the&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;sudo visudo /etc/sudoers&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
 command to open the sudoers file and lemme quickly go through the output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mj5rdvtU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzb0nvreocyetg3m0is9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mj5rdvtU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzb0nvreocyetg3m0is9.png" alt="Sudoers output" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*All line starting with # represents comments. (Not executed by the shell)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;root ALL=(ALL:ALL)ALL - this mean that the root user has unlimited privileges and can run any command&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;%admin ALL=(ALL)ALL - All % specifies a group, which mean anyone in the admin group has the same privilege as d root user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;%sudo ALL=(ALL:ALL) ALL - All users in the sudo group have the same privileges as the root user and can run any command.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I added the group devZ under the %sudo with the line&lt;/p&gt;

&lt;p&gt;%genZ ALL=(ALL:ALL) ALL&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lVDecYPB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqeqtaktk85dp5kwimwk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lVDecYPB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqeqtaktk85dp5kwimwk.png" alt="Group add" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then save the file, depending on the editor you are using.&lt;/p&gt;

&lt;p&gt;Another trick to know if your config file save successfully without any errors, use command&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo visudo -c&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z-G3nN83--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/helxsxizno6phks8c81h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z-G3nN83--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/helxsxizno6phks8c81h.png" alt="File save" width="800" height="102"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to confirm the file is OK, this is because it has permissions configuration which if mis-configured could log you completely and not have access to your server AGAIN. You want to be very careful with these configuration files.&lt;/p&gt;

&lt;p&gt;You need to reboot the system then try the sudo command again.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;reboot now&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Apply the exit command to take you back into the user, in this case afeez and try the sudo commands again&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OcuBdlve--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9fefb9w69t1gho9ij3y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OcuBdlve--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9fefb9w69t1gho9ij3y.png" alt="Sudo works now" width="800" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And BOOM! we now have access to the sudo command.&lt;/p&gt;

&lt;p&gt;I hope this helps.&lt;/p&gt;

&lt;p&gt;Thanks for reading :)&lt;/p&gt;

</description>
      <category>security</category>
      <category>devops</category>
      <category>opensource</category>
      <category>linux</category>
    </item>
    <item>
      <title>How to connect to a remote server securely using Open SSH (Secure SHell)</title>
      <dc:creator>tundek</dc:creator>
      <pubDate>Sat, 09 Sep 2023 10:37:54 +0000</pubDate>
      <link>https://dev.to/afeez/how-to-connect-to-a-remote-server-securely-using-open-ssh-secured-shell-jng</link>
      <guid>https://dev.to/afeez/how-to-connect-to-a-remote-server-securely-using-open-ssh-secured-shell-jng</guid>
      <description>&lt;p&gt;In this article i will be explaining how we can connect to a remote server using the Open SSH (Secured Shell) protocol.&lt;/p&gt;

&lt;p&gt;But before that, we will be getting some basic command checks out of the way.&lt;/p&gt;

&lt;p&gt;First, we check the client PC to ensure the SSH directory is currently empty.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -latr ~/.ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Db1T-rKh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oexiuv3nhg617a3eadfm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Db1T-rKh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oexiuv3nhg617a3eadfm.png" alt="Output of the above syntax" width="800" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1:
&lt;/h3&gt;

&lt;p&gt;Generate the SSH key pair (&lt;em&gt;SSH used the asymmetric cypher for encryption&lt;/em&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ssh-keygen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zrDVTtGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xkm69dqgsl8bqmwg6tgk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zrDVTtGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xkm69dqgsl8bqmwg6tgk.png" alt="Output of the sudo ssh-keygen command" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you noticed the above image, the SSH key pair was created in the /root/.ssh/ directory.&lt;/p&gt;

&lt;p&gt;Checking the directory to see the files generated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ls -ltar /root/.ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bU1xey4F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31p9n6tlywrv26wpf4o7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bU1xey4F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31p9n6tlywrv26wpf4o7.png" alt="Screenshot of the above command" width="800" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We are done with the client Configuration, SSH on the client has now been installed&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On to the Server now&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2:
&lt;/h3&gt;

&lt;p&gt;Install the Open SSH Server software on the Server itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install openssh-server -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3:
&lt;/h3&gt;

&lt;p&gt;Now we need to send/transfer the public key on the client computer to the Server using the command (utility tool on the client ssh) on the client:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ssh-copy-id -i /root/.ssh/id_rsa.pub username@serverIPAddress
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;








&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ssh-copy-id -i /root/.ssh/id_rsa.pub afeez@192.168.1.163
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;You can use the &lt;code&gt;ifconfig&lt;/code&gt; command to check the IP address of the server&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The public key will now be transferred into the server.&lt;/p&gt;

&lt;p&gt;To confirm this, run the command on the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls -ltar ~/.ssh 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--K_I5-MaD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39v5qeyf000k5hlkz013.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--K_I5-MaD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/39v5qeyf000k5hlkz013.png" alt="Comamnd output" width="800" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To confirm the public key is the same you can run a cat command on both files&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Step:
&lt;/h3&gt;

&lt;p&gt;Connect to the remote server using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh username@remoteserverIP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;








&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh afeez@192.168.1.163
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nssHbAk---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kgfni7uy0nlsbinp3ofe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nssHbAk---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kgfni7uy0nlsbinp3ofe.png" alt="Ooutput" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And BOOM!!!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F6NahrDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hg6dd4vv3qjz2h9g0wyj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F6NahrDP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hg6dd4vv3qjz2h9g0wyj.png" alt="Output" width="800" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are now connected to the Sever using SSH.&lt;/p&gt;

&lt;p&gt;I hope this helps.&lt;/p&gt;

</description>
      <category>security</category>
      <category>linux</category>
      <category>devops</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
