<?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: Matthew M Tarfa</title>
    <description>The latest articles on DEV Community by Matthew M Tarfa (@cloudforce).</description>
    <link>https://dev.to/cloudforce</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%2F904002%2Fdc3ac648-2793-4974-a2e7-e81deaa46724.jpg</url>
      <title>DEV Community: Matthew M Tarfa</title>
      <link>https://dev.to/cloudforce</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cloudforce"/>
    <language>en</language>
    <item>
      <title>Task Manager App with Flask and MySQL</title>
      <dc:creator>Matthew M Tarfa</dc:creator>
      <pubDate>Sat, 16 Nov 2024 00:15:11 +0000</pubDate>
      <link>https://dev.to/cloudforce/task-manager-app-with-flask-and-mysql-4gm5</link>
      <guid>https://dev.to/cloudforce/task-manager-app-with-flask-and-mysql-4gm5</guid>
      <description>&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;This project is a &lt;strong&gt;Task Manager App&lt;/strong&gt; built with Flask and MySQL. It provides a simple RESTful API to manage tasks, demonstrating basic CRUD (Create, Read, Delete) operations. &lt;/p&gt;

&lt;p&gt;This application is perfect for understanding how Flask applications can be containerized using Docker and connected with a MySQL database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Add new tasks&lt;/li&gt;
&lt;li&gt;View all tasks&lt;/li&gt;
&lt;li&gt;Delete a task by ID&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Flask Code: &lt;strong&gt;&lt;em&gt;app.py&lt;/em&gt;&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask, request, jsonify
import mysql.connector
from mysql.connector import Error

app = Flask(__name__)

# Database connection function
def get_db_connection():
    try:
        connection = mysql.connector.connect(
            host="db",
            user="root",
            password="example",
            database="task_db"
        )
        return connection
    except Error as e:
        return str(e)

# Route for the home page
@app.route('/')
def home():
    return "Welcome to the Task Management API! Use /tasks to interact with tasks."

# Route to create a new task
@app.route('/tasks', methods=['POST'])
def add_task():
    task_description = request.json.get('description')
    if not task_description:
        return jsonify({"error": "Task description is required"}), 400

    connection = get_db_connection()
    if isinstance(connection, str):  # If connection fails
        return jsonify({"error": connection}), 500

    cursor = connection.cursor()
    cursor.execute("INSERT INTO tasks (description) VALUES (%s)", (task_description,))
    connection.commit()
    task_id = cursor.lastrowid
    cursor.close()
    connection.close()

    return jsonify({"message": "Task added successfully", "task_id": task_id}), 201

# Route to get all tasks
@app.route('/tasks', methods=['GET'])
def get_tasks():
    connection = get_db_connection()
    if isinstance(connection, str):  # If connection fails
        return jsonify({"error": connection}), 500

    cursor = connection.cursor()
    cursor.execute("SELECT id, description FROM tasks")
    tasks = cursor.fetchall()
    cursor.close()
    connection.close()

    task_list = [{"id": task[0], "description": task[1]} for task in tasks]
    return jsonify(task_list), 200

# Route to delete a task by ID
@app.route('/tasks/&amp;lt;int:task_id&amp;gt;', methods=['DELETE'])
def delete_task(task_id):
    connection = get_db_connection()
    if isinstance(connection, str):  # If connection fails
        return jsonify({"error": connection}), 500

    cursor = connection.cursor()
    cursor.execute("DELETE FROM tasks WHERE id = %s", (task_id,))
    connection.commit()
    cursor.close()
    connection.close()

    return jsonify({"message": "Task deleted successfully"}), 200

if __name__ == "__main__":
    app.run(host='0.0.0.0')


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

&lt;/div&gt;



&lt;h2&gt;
  
  
  MySQL Database Setup Script
&lt;/h2&gt;

&lt;p&gt;Create a MySQL script named init-db.sql to set up the database and the tasks table:&lt;/p&gt;

&lt;p&gt;To create the init-db.sql script, follow these steps:&lt;/p&gt;

&lt;p&gt;Create a new &lt;strong&gt;file&lt;/strong&gt; in your project directory:&lt;/p&gt;

&lt;p&gt;Navigate to the project folder and create a new file named &lt;strong&gt;&lt;em&gt;init-db.sql&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Add &lt;strong&gt;SQL&lt;/strong&gt; commands to set up the database and tasks table:&lt;/p&gt;

&lt;p&gt;Open &lt;strong&gt;&lt;em&gt;init-db.sql&lt;/em&gt;&lt;/strong&gt; in a text editor and add the following SQL commands:&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 IF NOT EXISTS task_db;
USE task_db;

CREATE TABLE IF NOT EXISTS tasks (
    id INT AUTO_INCREMENT PRIMARY KEY,
    description VARCHAR(255) NOT NULL
);

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Save the file:
&lt;/h3&gt;

&lt;p&gt;I saved the file as &lt;strong&gt;&lt;em&gt;init-db.sql&lt;/em&gt;&lt;/strong&gt; in the project folder  where my &lt;strong&gt;&lt;em&gt;docker-compose.yml&lt;/em&gt;&lt;/strong&gt; is located.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In the docker-compose.yml:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In my &lt;strong&gt;&lt;em&gt;docker-compose.yml&lt;/em&gt;&lt;/strong&gt; file, I have the volumes configuration that points to this script.&lt;/p&gt;

&lt;p&gt;Below is the &lt;strong&gt;&lt;em&gt;docker-compose.yml&lt;/em&gt;&lt;/strong&gt; file&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker Configuration
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;docker-compose.yml:&lt;/em&gt;&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;version: '3'
services:
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: task_db
    ports:
      - "3306:3306"
    volumes:
      - db_data:/var/lib/mysql
      - ./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql

  web:
    build: .
    ports:
      - "5000:5000"
    depends_on:
      - db
    environment:
      FLASK_ENV: development
    volumes:
      - .:/app

volumes:
  db_data:

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

&lt;/div&gt;



&lt;p&gt;This configuration ensures that when the MySQL container starts, it will execute the &lt;strong&gt;&lt;em&gt;init-db.sql&lt;/em&gt;&lt;/strong&gt; script to set up the &lt;strong&gt;&lt;em&gt;task_db&lt;/em&gt;&lt;/strong&gt; database and create the &lt;strong&gt;tasks&lt;/strong&gt; table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The &lt;strong&gt;&lt;em&gt;docker-entrypoint-initdb.d/&lt;/em&gt;&lt;/strong&gt; directory is used by &lt;strong&gt;MySQL&lt;/strong&gt; containers to execute &lt;strong&gt;&lt;em&gt;.sql&lt;/em&gt;&lt;/strong&gt; scripts during the initial startup of the container.&lt;/p&gt;

&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. version: '3':&lt;/strong&gt; Specifies the version of Docker Compose being used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. services:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;db:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;image: mysql:5.7:&lt;/strong&gt; Uses the MySQL 5.7 image.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;environment:&lt;/strong&gt; Sets environment variables for the MySQL container:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MYSQL_ROOT_PASSWORD:&lt;/strong&gt; The root password for MySQL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MYSQL_DATABASE:&lt;/strong&gt; The database to be created at startup.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;ports:&lt;/strong&gt; Maps the MySQL container's port 3306 to your host's port 3306.&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;volumes:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;db_data:/var/lib/mysql:&lt;/em&gt;&lt;/strong&gt; Persists the database data in a Docker volume called &lt;strong&gt;&lt;em&gt;db_data.&lt;/em&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql:&lt;/em&gt;&lt;/strong&gt; Mounts the &lt;strong&gt;&lt;em&gt;init-db.sql&lt;/em&gt;&lt;/strong&gt; script into the &lt;strong&gt;MYSQL&lt;/strong&gt; container's initialization directory so it runs when the container starts.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;web:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;build:&lt;/strong&gt; .: Builds the Docker image for your Flask app using the &lt;strong&gt;&lt;em&gt;Dockerfile&lt;/em&gt;&lt;/strong&gt; in the current directory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ports:&lt;/strong&gt; Maps the Flask app's port 5000 to your host's port 5000.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;depends_on:&lt;/strong&gt; Ensures that the &lt;strong&gt;&lt;em&gt;db&lt;/em&gt;&lt;/strong&gt; service starts before the web service.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;environment:&lt;/strong&gt; Sets the environment variable for Flask.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;volumes:&lt;/strong&gt; Mounts the current project directory into the &lt;strong&gt;&lt;em&gt;/app&lt;/em&gt;&lt;/strong&gt; directory inside the container.
### volumes section:
&lt;strong&gt;db_data:&lt;/strong&gt; Defines a named volume db_data to persist the MySQL data between container restarts.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Dockerfile:
&lt;/h3&gt;

&lt;p&gt;Define the build instructions for the Flask app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM python:3.9-slim

WORKDIR /app

# Install dependencies

COPY requirements.txt .
RUN pip install -r requirements.txt

# Install wait-for-it tool#

RUN apt-get update &amp;amp;&amp;amp; apt-get install -y wait-for-it

#Copy the application code&amp;gt;

COPY . .

# Use wait-for-it to wait for DB and start the Flask app

CMD ["wait-for-it", "db:3306", "--", "python", "app.py"]

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

&lt;/div&gt;



&lt;p&gt;This Dockerfile sets up a lightweight Python environment for a Flask app:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Base Image:&lt;/strong&gt; Uses python:3.9-slim for minimal Python runtime.&lt;br&gt;
Working Directory: Sets /app as the working directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Dependencies:&lt;/strong&gt; Copies requirements.txt and installs dependencies via pip.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Tool Installation:&lt;/strong&gt; Installs wait-for-it for checking service readiness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Application Code:&lt;/strong&gt; Copies all app code into the container.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Startup Command:&lt;/strong&gt; Runs wait-for-it to ensure the MySQL DB (db:3306) is ready before starting app.py.&lt;/p&gt;
&lt;h3&gt;
  
  
  Requirements.txt File
&lt;/h3&gt;

&lt;p&gt;This &lt;strong&gt;&lt;em&gt;requirements.txt&lt;/em&gt;&lt;/strong&gt; specifies that the Python project requires the &lt;strong&gt;Flask framework&lt;/strong&gt; for building web applications and &lt;strong&gt;&lt;em&gt;mysql-connector-python&lt;/em&gt;&lt;/strong&gt; for connecting and interacting with a &lt;strong&gt;MySQL database&lt;/strong&gt;. These packages will be installed within the &lt;strong&gt;Docker&lt;/strong&gt; container when &lt;strong&gt;&lt;em&gt;pip install -r requirements.txt&lt;/em&gt;&lt;/strong&gt; is run during the image build process. This ensures the app has the necessary tools to run the &lt;strong&gt;Flask server&lt;/strong&gt; and communicate with the &lt;strong&gt;MySQL database&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;Flask
mysql-connector-python

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

&lt;/div&gt;



&lt;p&gt;After creating all the files the next step is to build and run the service the following command is used to build and run the  service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose build
docker-compose up

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

&lt;/div&gt;



&lt;p&gt;to run the service in a detached mode I used the following command instead of &lt;strong&gt;&lt;em&gt;docker-compose up&lt;/em&gt;&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;docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;when I want to stop the service I 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;docker-compose down
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now once the service is in the running state  run 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;docker ps 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to ensure the containers are running &lt;/p&gt;

&lt;p&gt;Now its time to check the service API to ensure they are working as expected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the Project
&lt;/h2&gt;

&lt;p&gt;Access the app at &lt;a href="http://localhost:5000/" rel="noopener noreferrer"&gt;http://localhost:5000/&lt;/a&gt; .&lt;br&gt;
 I was able to access the app on my browser after running the above command as seen in the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Ffda9f2rien7lf37dt1bt.PNG" class="article-body-image-wrapper"&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%2Farticles%2Ffda9f2rien7lf37dt1bt.PNG" alt="Image description" width="800" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use Postman or curl to test the /tasks endpoint for POST, GET, and DELETE operations. In ths case I would be using curl.&lt;/p&gt;
&lt;h3&gt;
  
  
  curl Commands:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Get Tasks:&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The GET method fetches all tasks.&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:5000/tasks

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2F5iary78vxqmpvye2i10w.PNG" class="article-body-image-wrapper"&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%2Farticles%2F5iary78vxqmpvye2i10w.PNG" alt="Image of task page" width="570" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that anytime you run &lt;a href="http://localhost:5000/tasks" rel="noopener noreferrer"&gt;http://localhost:5000/tasks&lt;/a&gt; on your browser it shows you all the task you have added as explained in the add task.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Add a Task:&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The POST method creates tasks in 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;curl -X POST http://localhost:5000/tasks -H "Content-Type: application/json" -d '{"description": "Sample Task"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will send a POST request to your Flask app with a task description. If the task is added successfully, you should receive a response like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "message": "Task added successfully",
    "task_id": 1
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;check your browser's network tab or logs to verify that the POST request is being made correctly.&lt;/p&gt;

&lt;p&gt;I ran the command a couple of times and customized the part where its says Simple Task to generate different outputs here are the commands I ran  and the out puts can be seen in the images below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; curl -X POST http://localhost:5000/tasks -H "Content-Type: application/json" -d '{"description": "My name is Matthew Tarfa am the Cloud Chief"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2Ftx8z2yco2jcym8tkh25e.PNG" class="article-body-image-wrapper"&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%2Farticles%2Ftx8z2yco2jcym8tkh25e.PNG" alt="Image description" width="788" height="335"&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; curl -X POST http://localhost:5000/tasks -H "Content-Type: application/json" -d '{"description": "Welcome to my World!"}'

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2F3egntby8jw66yisq2xsj.PNG" class="article-body-image-wrapper"&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%2Farticles%2F3egntby8jw66yisq2xsj.PNG" alt="Image description" width="800" height="310"&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; curl -X POST http://localhost:5000/tasks -H "Content-Type: application/json" -d '{"description": "I love DevOps!"}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2Fs4tl02exufuhuaweefsh.PNG" class="article-body-image-wrapper"&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%2Farticles%2Fs4tl02exufuhuaweefsh.PNG" alt="Image description" width="800" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;em&gt;Delete a Task:&lt;/em&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The DELETE method removes tasks by ID.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X DELETE http://localhost:5000/tasks/1

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

&lt;/div&gt;



&lt;p&gt;I ran the below command to remove the task with the ID:4 as seen in the image below task 4 has been removed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X DELETE http://localhost:5000/tasks/4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2F7v57jkc81gvh3f136t8l.PNG" class="article-body-image-wrapper"&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%2Farticles%2F7v57jkc81gvh3f136t8l.PNG" alt="delete image" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Creating a Task Manager App using Flask and MySQL is an excellent way to understand the fundamentals of web service development, database integration, and containerization with Docker. &lt;/p&gt;

&lt;p&gt;This project encapsulates how web servers and databases work in unison to provide seamless functionality. &lt;/p&gt;

&lt;p&gt;Embrace this learning experience and use it as a stepping stone to deeper web and cloud-based development projects.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>python</category>
      <category>aws</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Containerizing Python Data Processing Scripts with Docker: A Step-by-Step Guide</title>
      <dc:creator>Matthew M Tarfa</dc:creator>
      <pubDate>Thu, 14 Nov 2024 05:54:29 +0000</pubDate>
      <link>https://dev.to/cloudforce/containerizing-python-data-processing-scripts-with-docker-a-step-by-step-guide-166</link>
      <guid>https://dev.to/cloudforce/containerizing-python-data-processing-scripts-with-docker-a-step-by-step-guide-166</guid>
      <description>&lt;p&gt;Containerization is a game changer in modern software development, providing a consistent runtime environment for applications. In this blog post, I’ll guide you through a project where I containerized a Python script that reads and processes a CSV file using Docker. This is an excellent project for beginners looking to build a foundational understanding of Docker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Goal:&lt;/strong&gt; Containerize a Python script that processes data from a CSV file to make it portable and executable in any environment.&lt;br&gt;
&lt;strong&gt;Technologies Used:&lt;/strong&gt; Docker, Python, pandas&lt;/p&gt;
&lt;h2&gt;
  
  
  Real-World Application
&lt;/h2&gt;

&lt;p&gt;This type of data processing can be scaled up for more complex datasets, such as processing customer records, analyzing survey results, or even preliminary data cleaning for machine learning tasks. The ability to containerize this script ensures that it can run consistently across various environments, making it easier for teams to collaborate without worrying about dependency issues.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Create a Sample Data File
&lt;/h2&gt;

&lt;p&gt;For this project, we will use a sample CSV file named data.csv with six simple entries:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;data.csv&lt;/em&gt;&lt;/strong&gt; content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name
Oluchukwu
Matthew
John
Sola
Benson
Winston
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Write the Python Script
&lt;/h2&gt;

&lt;p&gt;Create a Python script named process_data.py to read and print a summary of the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;process_data.py&lt;/em&gt;&lt;/strong&gt; content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd

# Creating a DataFrame from the CSV file
df = pd.read_csv('data.csv', header=None, names=['Name'])  # Assuming no header in the CSV file

# Generating the summary statistics of the 'Name' column
description = df['Name'].describe()

# Printing the description of the 'Name' column
print(description)

# Additional print to show unique value count explicitly
print("Unique values count:")
print(df['Name'].nunique())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation of the Code:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Reading the CSV:&lt;/strong&gt; The header=None argument tells pandas that the CSV doesn't have a header row, and the &lt;strong&gt;&lt;em&gt;names=['Name']&lt;/em&gt;&lt;/strong&gt; argument assigns the name Name to the single column in the CSV.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generating Summary:&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;df['Name'].describe()&lt;/em&gt;&lt;/strong&gt; gives you the summary statistics for the Name column, including count, unique values, the most frequent value (top), and its frequency (freq).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Printing Unique Values Count:&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;df['Name'].nunique()&lt;/em&gt;&lt;/strong&gt; directly shows the number of unique names in the column.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Create a &lt;strong&gt;&lt;em&gt;requirements.txt&lt;/em&gt;&lt;/strong&gt; File
&lt;/h2&gt;

&lt;p&gt;The requirements.txt file specifies the Python dependencies required by the script:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
This ensures that the pandas library is installed when building the Docker image.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 4: Write the Dockerfile
&lt;/h2&gt;

&lt;p&gt;The Dockerfile defines the environment and commands for building the container. Here’s what it should look like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Dockerfile&lt;/em&gt;&lt;/strong&gt; content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use a minimal Python base image
FROM python:3.9-slim

# Set the working directory inside the container
WORKDIR /app

# Copy the requirements file into the container
COPY requirements.txt .

# Install the required Python libraries
RUN pip install -r requirements.txt

# Copy the rest of the project files into the container
COPY . .

# Define the command to run the Python script
CMD ["python", "process_data.py"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;FROM &lt;strong&gt;&lt;em&gt;python:3.9-slim&lt;/em&gt;&lt;/strong&gt;: Specifies a lightweight Python image as the base.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;WORKDIR /app&lt;/em&gt;&lt;/strong&gt;: Sets the working directory for the container.&lt;/li&gt;
&lt;li&gt;COPY &lt;strong&gt;&lt;em&gt;requirements.txt .&lt;/em&gt;&lt;/strong&gt; : Copies &lt;strong&gt;&lt;em&gt;requirements.txt&lt;/em&gt;&lt;/strong&gt; to the container.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;RUN pip install -r requirements.txt&lt;/em&gt;&lt;/strong&gt; : Installs Python dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;COPY . .&lt;/em&gt;&lt;/strong&gt; : Copies the project files into the container.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;CMD ["python", "process_data.py"]&lt;/em&gt;&lt;/strong&gt;: Specifies the command to run the script.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: Build the Docker Image
&lt;/h2&gt;

&lt;p&gt;Navigate to the project directory and build the Docker image with 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;docker build -t python-script .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;docker build: Command to build a Docker image.&lt;/li&gt;
&lt;li&gt;-t python-script: Tags the image with the name python-script.&lt;/li&gt;
&lt;li&gt;. (dot): Specifies the current directory as the build context.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 6: Run the Docker Container
&lt;/h2&gt;

&lt;p&gt;Run the container and mount the &lt;strong&gt;&lt;em&gt;data&lt;/em&gt;&lt;/strong&gt; directory to ensure the script can access the &lt;strong&gt;CSV file&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;docker run -v $(pwd)/data:/app/data python-script
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;docker run&lt;/em&gt;&lt;/strong&gt;: Runs a Docker container.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;-v $(pwd)/data:/app/data&lt;/em&gt;&lt;/strong&gt;: Mounts the data directory from your host machine to &lt;strong&gt;&lt;em&gt;/app/data&lt;/em&gt;&lt;/strong&gt; in the container.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;python-script:&lt;/em&gt;&lt;/strong&gt; The name of the Docker image to run.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 7: Check the Output
&lt;/h2&gt;

&lt;p&gt;After running the Docker container, you should see an output that summarizes the contents of data.csv. Here’s the actual output from the project&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&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;            Name
count          6
unique         6
top       Oluchukwu
freq           1
Unique values count:
6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Understanding the Output:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;count&lt;/strong&gt;: 6 – This shows that there are 6 values in the Name column. The count function counts the number of non-null entries, which is 6 in this case.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;unique&lt;/strong&gt;: 6 – This means that there are 6 unique names in the column. Since all 6 names provided (Oluchukwu, Matthew, John, Sola, Benson, Winston) are distinct, it counts all 6 as unique.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;top&lt;/strong&gt;: Oluchukwu – This tells that the most frequent name in the Name column. Since no name appears more than once in the file, pandas defaults to the first name in the column (in this case, Oluchukwu).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;freq&lt;/strong&gt;: 1 – This shows the frequency of the most frequent name, which is 1 because every name appears exactly once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unique values count&lt;/strong&gt;: 6:
This is showing that there are 6 unique names in the dataset, which matches the number of names in the CSV file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why Oluchukwu is listed as the top value:&lt;/strong&gt;&lt;br&gt;
In the dataset, no name is repeated, so pandas automatically picks the first name in the list, Oluchukwu, as the top value because it’s the most frequent by default.&lt;/p&gt;

&lt;p&gt;6 unique names means there are 6 distinct entries, which is correct.&lt;br&gt;
The top value of Oluchukwu is due to it being the first value in the list since there is no repetition.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By following these steps, you've successfully containerized a Python data processing script. This approach ensures that your script runs consistently across different environments, making it a valuable tool for data analysis tasks. You can further enhance this project by integrating it with cloud platforms or automating the container execution using CI/CD pipelines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps:
&lt;/h2&gt;

&lt;p&gt;Try expanding the script to include data cleaning, visualization, or exporting processed data. You can also explore deploying the container to a cloud service like &lt;strong&gt;&lt;em&gt;AWS ECS or Kubernetes&lt;/em&gt;&lt;/strong&gt; for a scalable data processing solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ready to elevate your data processing projects? Start containerizing today and unlock the full potential of Docker!&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Effortless Web Hosting: Build and Run an NGINX Server with Docker</title>
      <dc:creator>Matthew M Tarfa</dc:creator>
      <pubDate>Wed, 13 Nov 2024 09:52:13 +0000</pubDate>
      <link>https://dev.to/cloudforce/effortless-web-hosting-build-and-run-an-nginx-server-with-docker-11b8</link>
      <guid>https://dev.to/cloudforce/effortless-web-hosting-build-and-run-an-nginx-server-with-docker-11b8</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Docker has transformed the way we deploy applications, making processes more efficient and consistent. Whether you're developing locally or deploying to production, Docker ensures your web server behaves the same way, regardless of where it’s running. &lt;/p&gt;

&lt;p&gt;This guide will walk you through the process of creating an NGINX web server using Docker, providing a hands-on approach and practical insights along the way.&lt;/p&gt;

&lt;p&gt;Why Use Docker for Your NGINX Web Server?&lt;br&gt;
In traditional setups, creating an environment for your web server often involves installing and configuring software manually on each platform. &lt;/p&gt;

&lt;p&gt;With Docker, you can package your server and its dependencies into a container that runs seamlessly anywhere. This approach is particularly useful for developers and DevOps engineers who need consistency across development, staging, and production environments.&lt;/p&gt;
&lt;h2&gt;
  
  
  Benefits of Using Docker:
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Consistency:
&lt;/h3&gt;

&lt;p&gt;Containers ensure your server runs the same way in all environments.&lt;/p&gt;
&lt;h3&gt;
  
  
  Portability:
&lt;/h3&gt;

&lt;p&gt;Easily move your containerized server across various platforms and clouds.&lt;/p&gt;
&lt;h3&gt;
  
  
  Rapid Deployment:
&lt;/h3&gt;

&lt;p&gt;Go from code to running application within minutes.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step-by-Step Guide to Deploying an NGINX Web Server with Docker
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set Up Your Project Directory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start by creating a directory for your project. This will help keep all your files organized.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir docker-project1
cd docker-project 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2Ff2phv48j1xy1gpozjhi3.PNG" class="article-body-image-wrapper"&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%2Farticles%2Ff2phv48j1xy1gpozjhi3.PNG" alt="create project folder" width="491" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create Your Web Content&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a simple index.html file that will serve as the homepage for your web server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch index.html
nano index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2F1fjs1bbvzak0rky7ve1t.PNG" class="article-body-image-wrapper"&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%2Farticles%2F1fjs1bbvzak0rky7ve1t.PNG" alt="create index.html file" width="636" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add some basic content to your index.html file:&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2F4e5y198n5wh0z9xrswjx.PNG" class="article-body-image-wrapper"&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%2Farticles%2F4e5y198n5wh0z9xrswjx.PNG" alt="content of Index file" width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;**Step 3: Write Your Dockerfile&lt;/em&gt;*&lt;/p&gt;

&lt;p&gt;The Dockerfile is the blueprint for building your Docker image. It contains instructions for setting up your environment. Create a &lt;strong&gt;&lt;em&gt;Dockerfile&lt;/em&gt;&lt;/strong&gt; in your project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch Dockerfile
nano Dockerfile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2Fuhmib22qi5ont0tkkhb1.PNG" class="article-body-image-wrapper"&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%2Farticles%2Fuhmib22qi5ont0tkkhb1.PNG" alt="create docker file" width="499" height="202"&gt;&lt;/a&gt;&lt;br&gt;
Add the following lines to your Dockerfile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Use the official NGINX base image
FROM nginx:alpine

# Copy the content of your HTML file to the default NGINX directory
COPY index.html /usr/share/nginx/html/index.html

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2Fno0q9xji1bim09ilx540.PNG" class="article-body-image-wrapper"&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%2Farticles%2Fno0q9xji1bim09ilx540.PNG" alt="dockerfile content" width="411" height="146"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Explanation of the Dockerfile:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FROM nginx&lt;/strong&gt;
: Specifies the lightweight NGINX base image to use.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;COPY:&lt;/strong&gt; Transfers your &lt;strong&gt;&lt;em&gt;index.html&lt;/em&gt;&lt;/strong&gt; file into the appropriate directory within the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Build Your Docker Image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With your Dockerfile ready, build your Docker image by running:&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 my-nginx-server .

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2F3hakf5sqny96s0ew9pxx.PNG" class="article-body-image-wrapper"&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%2Farticles%2F3hakf5sqny96s0ew9pxx.PNG" alt="image of docker build command" width="589" height="109"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This command creates an image named &lt;strong&gt;&lt;em&gt;my-nginx-server&lt;/em&gt;&lt;/strong&gt; based on your Dockerfile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Run Your NGINX Container&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start your container 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;docker run -d -p 8080:80 my-nginx-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="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%2Farticles%2Fsmsonbw9xawv0mm9xxxc.PNG" class="article-body-image-wrapper"&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%2Farticles%2Fsmsonbw9xawv0mm9xxxc.PNG" alt="run image" width="700" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;-d: Runs the container in detached mode.&lt;/li&gt;
&lt;li&gt;-p 8080:80: Maps port 8080 on your machine to port 80 inside the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Access Your Web Server&lt;/strong&gt;&lt;br&gt;
Open your web browser and navigate to  &lt;strong&gt;&lt;em&gt;&lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt; You should see your &lt;strong&gt;"HTML!"&lt;/strong&gt; message displayed, confirming that your &lt;strong&gt;NGINX&lt;/strong&gt; server is up and running inside a Docker container.&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fej58jiqbr30icpokitjn.PNG" class="article-body-image-wrapper"&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%2Farticles%2Fej58jiqbr30icpokitjn.PNG" alt="pic of output" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Real-Life Use Case
&lt;/h3&gt;

&lt;p&gt;Imagine a scenario where a software development team needs to quickly test changes to their website before deploying to production.&lt;/p&gt;

&lt;p&gt;By containerizing their NGINX server, they can ensure that everyone on the team sees the same results locally as they would in a staging or production environment. &lt;/p&gt;

&lt;p&gt;This dramatically reduces the risk of discrepancies due to "it works on my machine" issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Setting up an NGINX web server with Docker streamlines your deployment process, making it easier to create, test, and run web servers consistently across various environments. &lt;/p&gt;

&lt;p&gt;This guide shows how simple it is to build and launch your server using Docker's powerful yet user-friendly tools.&lt;/p&gt;

&lt;p&gt;Start using Docker for your projects today, and unlock a new level of efficiency and consistency in your deployments!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>aws</category>
      <category>learning</category>
    </item>
    <item>
      <title>AWS Cost Optimization: A Practical Guide to Maximizing Efficiency</title>
      <dc:creator>Matthew M Tarfa</dc:creator>
      <pubDate>Thu, 24 Oct 2024 14:49:52 +0000</pubDate>
      <link>https://dev.to/cloudforce/aws-cost-optimization-a-practical-guide-to-maximizing-efficiency-13dk</link>
      <guid>https://dev.to/cloudforce/aws-cost-optimization-a-practical-guide-to-maximizing-efficiency-13dk</guid>
      <description>&lt;p&gt;In today's fast-paced tech landscape, where cloud computing has become the backbone of businesses, optimizing costs on cloud platforms like AWS is no longer a luxury—it's a necessity. While AWS offers a wide array of services that allow businesses to scale, it’s easy to lose track of costs when not managed properly.&lt;/p&gt;

&lt;p&gt;AWS cost optimization is about making the most out of your cloud resources by using the right services, scaling intelligently, and eliminating waste. In this blog, we'll dive into practical scenarios, services, and strategies that can help organizations cut down on cloud expenditure while still leveraging the full potential of AWS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why AWS Cost Optimization Matters
&lt;/h2&gt;

&lt;p&gt;For many organizations, moving to the cloud can feel like a never-ending financial commitment. Without proper planning, cloud bills can quickly spiral out of control. However, AWS provides tools and services that allow businesses to gain visibility into their cloud usage and make informed decisions that align with both technical and financial goals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s why cost optimization is crucial:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Financial Health:&lt;/strong&gt; Reduced costs directly impact profitability.&lt;br&gt;
&lt;strong&gt;Scalability:&lt;/strong&gt; Efficient cost management allows more resources to be allocated for growth and innovation.&lt;br&gt;
&lt;strong&gt;Sustainability:&lt;/strong&gt; Cost optimization ensures that cloud resources are used sustainably, reducing waste.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key AWS Services for Cost Optimization
&lt;/h2&gt;

&lt;p&gt;AWS offers several services and tools that help businesses monitor and optimize their cloud spending. Here are some essential ones:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;AWS Cost Explorer&lt;/strong&gt;: Helps visualize and analyze cloud costs and usage patterns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Budgets:&lt;/strong&gt; Allows users to set custom cost and usage budgets and receive alerts when they exceed thresholds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Trusted Advisor&lt;/strong&gt;: Provides real-time recommendations, focusing on cost optimization, performance, and security.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Compute Optimizer:&lt;/strong&gt; Recommends optimal instance types based on usage to avoid over-provisioning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Lambda:&lt;/strong&gt; Helps cut costs by charging based on the actual compute time used rather than reserved resources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon S3 Intelligent-Tiering&lt;/strong&gt;: Automatically moves data to the most cost-effective storage tier based on access patterns.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon RDS:&lt;/strong&gt; Supports cost savings through Reserved Instances and by enabling automatic backups and data replication.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Real-Life Scenarios of AWS Cost Optimization
&lt;/h2&gt;

&lt;p&gt;Let's look at some practical use cases of AWS cost optimization:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 1: EC2 Right-Sizing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; A fast-growing e-commerce business runs multiple large EC2 instances that are rarely at full capacity, resulting in underutilization of resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; By using AWS Compute Optimizer, they discover they can downsize several instances without affecting performance. They switch from expensive on-demand instances to Reserved Instances for their predictable workloads, saving up to 60% annually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Impact:&lt;/strong&gt; The business dramatically reduces its cloud bill while ensuring optimal resource use, allowing it to invest in marketing campaigns instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 2:&lt;/strong&gt; Data Storage Optimization with S3&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; A media company stores petabytes of video data on Amazon S3 Standard, even though a large percentage of the data is rarely accessed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Using S3 Intelligent-Tiering, the company automatically moves infrequently accessed data to lower-cost storage tiers, like S3 Glacier or S3 Deep Archive, where storage is significantly cheaper.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Impact:&lt;/strong&gt; The company reduces storage costs by over 50% without any loss of data availability, freeing up funds for content creation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 3:&lt;/strong&gt; Serverless Architecture with Lambda&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; A startup uses EC2 instances to run a backend service, even though the service only receives intermittent traffic. During periods of low usage, they still pay for the idle EC2 instances.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; They switch to a serverless architecture using AWS Lambda, which scales automatically and only charges them for actual compute time used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Impact:&lt;/strong&gt; The startup’s operational costs drop by 70%, allowing them to reinvest savings into R&amp;amp;D while maintaining application performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario 4:&lt;/strong&gt; Optimizing Database Costs with RDS Reserved Instances&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; A FinTech company runs several on-demand RDS instances for its production databases. The databases are always online and experience stable usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; By transitioning to RDS Reserved Instances for its production databases, the company locks in lower pricing for a year.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Impact:&lt;/strong&gt; The company achieves a 30% reduction in database costs, enabling it to scale other critical infrastructure like data pipelines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for AWS Cost Optimization
&lt;/h2&gt;

&lt;p&gt;Here are some actionable tips to ensure you’re getting the most out of AWS without breaking the bank:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Right-Sizing Instances: Use AWS Compute Optimizer and Trusted Advisor to right-size your EC2, RDS, and other instance-based services. Over-provisioning resources is one of the most common mistakes businesses make.&lt;/li&gt;
&lt;li&gt;Use Reserved Instances and Savings Plans: For predictable workloads, leverage EC2 Reserved Instances and Savings Plans to lock in lower rates. These can offer significant savings, especially for long-term, stable workloads.&lt;/li&gt;
&lt;li&gt;Leverage Auto Scaling: Configure Auto Scaling for your applications to ensure you're not paying for unused capacity. Auto Scaling ensures that your environment scales in and out based on actual demand.&lt;/li&gt;
&lt;li&gt;Monitor Unused Resources: Regularly audit your AWS environment for unused resources like idle EC2 instances, unattached EBS volumes, or outdated snapshots, and terminate or clean them up. &lt;/li&gt;
&lt;li&gt;Use Cost-Effective Storage Solutions: Optimize your S3 costs by using S3 Intelligent-Tiering or S3 Glacier for long-term storage and infrequent access. &lt;/li&gt;
&lt;li&gt;Optimize Lambda Usage: AWS Lambda can help reduce costs for intermittent workloads as it only charges for the time your code is executing. Ensure your Lambda function memory and execution time are optimized for further cost savings. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How Cost Optimization Impacts Business Growth
&lt;/h2&gt;

&lt;p&gt;Optimizing AWS costs has direct and indirect impacts on business operations. Here’s how:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Cost optimization allows you to reinvest savings into scaling your infrastructure, introducing new features, or improving service offerings.&lt;br&gt;
&lt;strong&gt;Flexibility:&lt;/strong&gt; With optimized costs, businesses have more room to experiment with new technologies and innovations without worrying about the financial burden.&lt;br&gt;
&lt;strong&gt;Operational Efficiency:&lt;/strong&gt; By eliminating unnecessary expenditures, organizations can streamline operations, making them more efficient and sustainable.&lt;br&gt;
For instance, a business that reduces its EC2 costs by 40% could use those funds to implement new machine learning models, driving better customer engagement and business intelligence.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;AWS cost optimization isn't about cutting corners; it's about maximizing the value of your cloud investment. By leveraging AWS’s wide range of services—such as Compute Optimizer, Reserved Instances, Lambda, and S3 Intelligent-Tiering—you can create a cloud environment that is both highly functional and financially efficient.&lt;/p&gt;

&lt;p&gt;When done right, cost optimization doesn't just reduce expenses—it can drive growth, enable innovation, and improve the overall agility of your business. Start small, analyze your current usage patterns, and implement strategies incrementally. Your business will thank you for it in the long run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ready to start your AWS cost optimization journey?&lt;/strong&gt; Explore these tools and strategies today and see the impact they can have on your business!&lt;/p&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>cloudcomputing</category>
      <category>awschallenge</category>
    </item>
    <item>
      <title>Elevating Excellence: Deploying a High-Performance LEMP Stack Web Server on AWS Cloud</title>
      <dc:creator>Matthew M Tarfa</dc:creator>
      <pubDate>Tue, 12 Mar 2024 13:21:54 +0000</pubDate>
      <link>https://dev.to/cloudforce/elevating-excellence-deploying-a-high-performance-lemp-stack-web-server-on-aws-cloud-2l2j</link>
      <guid>https://dev.to/cloudforce/elevating-excellence-deploying-a-high-performance-lemp-stack-web-server-on-aws-cloud-2l2j</guid>
      <description>&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;Embark on this exciting journey with me as I show you how to establish a robust web infrastructure on AWS, as I guide you through the meticulous process of deploying a LEMP (Linux, Nginx, MySQL, PHP) stack on the dynamic landscape of AWS Cloud. In this comprehensive guide, We'll lay the foundation for high-performance web applications, unlocking the full potential of cloud-based innovation.&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 1: Launching an EC2 Instance
&lt;/h2&gt;

&lt;p&gt;Log in to your AWS Management Console.&lt;br&gt;
Navigate to the EC2 dashboard and click "Launch Instance."&lt;/p&gt;

&lt;p&gt;We choose an Amazon Machine Image (AMI) for this project We would be using Ubuntu 22.04, select an instance type We would be using the t2 micro, configure instance details, add storage, and configure security groups to allow SSH (port 22) this grants us secured access into our instance and HTTP (port 80) traffic.&lt;/p&gt;

&lt;p&gt;Review the settings and launch the instance.&lt;/p&gt;

&lt;p&gt;Once the instance is running, connect to it using SSH. Use the private key associated with your key pair.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2:  Update server package index and Install the Nginx Web Server
&lt;/h2&gt;

&lt;p&gt;To showcase our web pages to our visitors, we'll leverage Nginx, a high-performance web server. Utilizing the apt package manager, we'll streamline the installation process. As a first step, update our server's package index, and then proceed with installing Nginx using apt install.&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 update
sudo apt install nginx
&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%2Fbupkfqu7mhtl7ls5zvfk.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%2Fbupkfqu7mhtl7ls5zvfk.PNG" alt="Lempstack" width="788" height="678"&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%2F8wu1dnljcpof3yoowbdw.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%2F8wu1dnljcpof3yoowbdw.PNG" alt="Lempstack" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When prompted, enter 'Y' to confirm the Nginx installation. Once the installation is complete, the Nginx web server will be active on our Ubuntu 20.04 server. To confirm a successful installation and check the service status, 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 systemctl status nginx
&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%2Fdys7jjigkmaamvxkkbnp.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%2Fdys7jjigkmaamvxkkbnp.PNG" alt="Lempstack" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the status is green and indicates that it's running, congratulations! We've successfully set up your first web server in the clouds. Well done!&lt;/p&gt;

&lt;p&gt;To access the server locally from Git bash terminal use: curl &lt;code&gt;http://localhost:80&lt;/code&gt;&lt;br&gt;&lt;br&gt;
Or curl &lt;code&gt;http://127.0.0.1:80&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%2Fs5u4ttd3snja01d8x1lh.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%2Fs5u4ttd3snja01d8x1lh.PNG" alt="Lempstack" width="615" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now to assess how our Nginx server responds to internet requests, enter your public IP address &lt;code&gt;(http://Public-IP-Address:80)&lt;/code&gt; into a web browser. The format should resemble 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%2F3tm1uzdiy1xksuo3bjgf.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%2F3tm1uzdiy1xksuo3bjgf.PNG" alt="Lempstack" width="800" height="313"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This shows that the web server is now correctly installed and accessible through our firewal&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 3: Installing MySQL
&lt;/h2&gt;

&lt;p&gt;With our web server operational, the next step is to install a Database Management System (DBMS) to store and manage data for our site. MySQL, a widely used relational database management system in PHP environments, will be our choice for this project. Let's proceed with its installation.&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;&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%2Faigtbtugqpicq6cbi1ob.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%2Faigtbtugqpicq6cbi1ob.PNG" alt="Lempstack" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When prompted, confirm the MySQL installation by typing 'Y' and pressing ENTER.&lt;/p&gt;

&lt;p&gt;Once the installation is complete, access the MySQL console by typing:&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;&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%2Ficce90g1pi1wudhtwg6s.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%2Ficce90g1pi1wudhtwg6s.PNG" alt="Lempstack" width="668" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;MySQL settings and enhance security. Run the security script by executing:&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 'PassWord1@';
&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%2F3vbwscxr8b4qqf7f09i6.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%2F3vbwscxr8b4qqf7f09i6.PNG" alt="Lampstack" width="714" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;where we have password1@ input  your own reliable and strong password.&lt;/p&gt;

&lt;p&gt;Exit the MySQL shell with:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Start the interactive script by running:&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;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%2Fp5ps4kgq6rg41ho3orh3.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%2Fp5ps4kgq6rg41ho3orh3.PNG" alt="Lempstack" width="765" height="707"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Accept the configuration of the VALIDATE PASSWORD PLUGIN when prompted this is if you want the existing password to be changed. Choose one of the three levels for the password validation policy, and then enter a new password corresponding to the selected policy level.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Subsequently, type 'Y' and press Enter at the following prompt. This action will remove any anonymous users and the test database, disable remote root logins, and implement the new rules to ensure that MySQL immediately incorporates the changes we've made.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When we are finished, we test if we are able to log in to the MySQL console by typing:&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 -p
&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%2F7szjcdslt4nin4fhu0i5.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%2F7szjcdslt4nin4fhu0i5.PNG" alt="Lempstack" width="598" height="354"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice the -p flag in this command, which will prompt us for the password used after changing the root user password.&lt;/p&gt;

&lt;p&gt;To exit the MySQL console, type:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Notice that we need to provide a password to connect as the root user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Installing PHP
&lt;/h2&gt;

&lt;p&gt;To process code and generate dynamic content, PHP needs to be installed alongside Nginx and MySQL. &lt;/p&gt;

&lt;p&gt;Unlike Apache, which embeds the PHP interpreter in each request, Nginx requires an external program to handle PHP processing. &lt;/p&gt;

&lt;p&gt;This program, called php-fpm (PHP FastCGI Process Manager), acts as a bridge between the PHP interpreter and the web server, enhancing overall performance for most PHP-based websites.&lt;/p&gt;

&lt;p&gt;Additionally, installing php-mysql allows PHP to communicate with MySQL-based databases.&lt;/p&gt;

&lt;p&gt;To install both packages simultaneously, execute 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;sudo apt install php-fpm php-mysql
&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%2Fbktnn50klexcse1mw4xm.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%2Fbktnn50klexcse1mw4xm.PNG" alt="Lempstack" width="800" height="597"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Confirm the installation by typing 'Y' and pressing ENTER when prompted.&lt;/p&gt;

&lt;p&gt;With the PHP components now installed, the next step involves configuring Nginx to utilize them effectively. Let's proceed with the configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 5: CONFIGURING NGINX TO USE PHP PROCESSOR
&lt;/h2&gt;

&lt;p&gt;In Nginx, akin to Apache's virtual hosts, server blocks can host multiple domains on one server. For this guide, we'll use "projectLEMP" as an example domain.&lt;/p&gt;

&lt;p&gt;By default, Ubuntu 20.04's Nginx serves from /var/www/html. Managing multiple sites is easier by creating domain-specific directories within /var/&lt;a href="http://www"&gt;www&lt;/a&gt;. This leaves /var/www/html as the default directory for unmatched requests.&lt;/p&gt;

&lt;p&gt;To create the root directory for "your_domain," follow these steps:&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;Next, assign ownership of the directory with the $USER environment variable, which will reference our current system 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;&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%2Fw3k6bow43rbfwiwiu77g.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%2Fw3k6bow43rbfwiwiu77g.PNG" alt="Lempstack" width="545" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;opening a new configuration file in Nginx’s sites-available directory called projectLEMP:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Add the following script in the file created:&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;&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%2Fm96a14buxnzqctm5e94k.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%2Fm96a14buxnzqctm5e94k.PNG" alt="Lempstack" width="800" height="361"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Activate the configuration by linking to the config file from Nginx's sites-enabled directory:
&lt;/li&gt;
&lt;/ul&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;ul&gt;
&lt;li&gt;Test the configuration for syntax errors:
&lt;/li&gt;
&lt;/ul&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;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%2Fvtxel3cdmo9hjwyj8ajk.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%2Fvtxel3cdmo9hjwyj8ajk.PNG" alt="Lempstack" width="764" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Disable the default Nginx host configured on port 80:
&lt;/li&gt;
&lt;/ul&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;ul&gt;
&lt;li&gt;Reload Nginx to apply the changes:
&lt;/li&gt;
&lt;/ul&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;&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%2Fz2rpda34f2axvoq2nm8l.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%2Fz2rpda34f2axvoq2nm8l.PNG" alt="Lempstack" width="541" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create an index.html file in the root web directory to test the new server block:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ sudo bash -c "echo -e 'Hello LEMP from hostname\n&amp;lt;h2&amp;gt;MATTHEW Cloud Force&amp;lt;/h2&amp;gt;\n&amp;lt;h3&amp;gt;It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change.&amp;lt;/h3&amp;gt;' &amp;gt; /var/www/projectLEMP/index.html"
&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%2Fwfi79ljw8acfdqug277f.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%2Fwfi79ljw8acfdqug277f.PNG" alt="Lempstack" width="800" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we go to our browser and try to open our website URL using IP address:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://&amp;lt;Public-IP-Address&amp;gt;:80&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We should see the below output&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%2F4ypbe12yc1y3ta0y5hhs.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%2F4ypbe12yc1y3ta0y5hhs.PNG" alt="Lempstack" width="800" height="201"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our LEMP stack is now fully configured. In the next step, we'll create a PHP script to ensure that Nginx can handle .php files within our newly configured website.&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 5: TESTING PHP WITH NGINX
&lt;/h2&gt;

&lt;p&gt;In this phase, we will examine the functionality of PHP within the Nginx environment to ensure seamless integration.To validate that Nginx can correctly hand .php files off to my PHP processor is by creating a test PHP file in the root web document:&lt;/p&gt;

&lt;p&gt;Create a file called info.php:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano /var/www/projectLEMP/info.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following script:&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;p&gt;To access this page in the web browser, use the following URL: &lt;code&gt;http://Public_IP_address/info.php&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%2Fkhmrnummce52qh2csxm2.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%2Fkhmrnummce52qh2csxm2.PNG" alt="Lempstack" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After reviewing the pertinent information about our PHP server on that page, it's advisable to remove the file you created, as it contains sensitive details about our PHP environment and our Ubuntu server. We can use the rm command to delete that file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo rm /var/www/projectLEMP/info.php

&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%2Frxvh090u4b8yaodu9jf3.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%2Frxvh090u4b8yaodu9jf3.PNG" alt="Lempstack" width="604" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can always regenerate this file if we need it later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Retrieving data from MySQL database with PHP
&lt;/h2&gt;

&lt;p&gt;In this step, we'll create a test database (DB) with a simple "To-Do list" and configure access to it. This setup allows the Nginx website to query data from the DB and display it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First is connecting to MySQL console:&lt;code&gt;$ sudo mysql -p&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating a new user and granting full privileges on the database using &lt;code&gt;mysql_native_password&lt;/code&gt; as the default authentication method:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE USER 'example_user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT ALL ON example_database.* TO 'example_user'@'%';

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

&lt;/div&gt;



&lt;p&gt;Replace 'example_user' with our desired username and 'password' with a strong and secure password. This ensures that the new user has the necessary permissions on the specified database. Here we would be using example-user as our username and PassWord1@ as our password. ensure the password meets the security password validation policy standard we selected earlier if not it would throw an error.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YnU8yLLA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/assets/pic21.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YnU8yLLA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/v1/assets/pic21.PNG" alt="lampstack pic" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Exiting from MySQL console:&lt;code&gt;mysql&amp;gt; exit&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can test if the new user has the proper permissions by logging into the MySQL console again, this time using the custom user credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql -u example_user -p

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

&lt;/div&gt;



&lt;p&gt;Confirm that we have access to the example_database database:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;This will give you the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Output
+--------------------+
| Database           |
+--------------------+
| example_database   |
| information_schema |
+--------------------+
2 rows in set (0.000 sec)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we’ll create a test table named todo_list. From the MySQL console, run the following statement:&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 example_database.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;&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%2Faki6ua2ix79jvctkdg2y.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%2Faki6ua2ix79jvctkdg2y.PNG" alt="Lempstack" width="448" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Insert a few rows of content in the test table. We might want to repeat the next command a few times, using different VALUES:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql&amp;gt; INSERT INTO example_database.todo_list (content) VALUES ("My first important item");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To confirm that the data was successfully saved to our table, run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;We should see the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Output
+---------+--------------------------+
| item_id | content                  |
+---------+--------------------------+
|       1 | My first important item  |
|       2 | My second important item |
|       3 | My third important item  |
|       4 | Other Items on the List  |
+---------+--------------------------+
4 rows in set (0.000 sec)
&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%2Ffacpdevnibekvrb3bovv.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%2Ffacpdevnibekvrb3bovv.PNG" alt="Lempstack" width="661" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After we confirm that we have valid data in our test table, we can exit the MySQL console:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Creating a new PHP file named &lt;code&gt;todo_list.php&lt;/code&gt; in our custom web root directory and generating a PHP script to connect to MySQL and query for our content can be achieved with 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;nano /var/www/projectLEMP/todo_list.php

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

&lt;/div&gt;



&lt;p&gt;This command opens the Nano text editor for you to create and edit the &lt;code&gt;todo_list.php&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Add the following PHP script:&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 = "example_user";
$password = "PassWord1@";
$database = "example_database";
$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;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%2Fiyvqbbilqphc00xlhcrh.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%2Fiyvqbbilqphc00xlhcrh.PNG" alt="Lempstack" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Save and close the file when we are done editing.&lt;/p&gt;

&lt;p&gt;We can now access this page in our web browser by visiting the domain name or public IP address configured for our website, followed by &lt;code&gt;/todo_list.php&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;http://&amp;lt;Public_domain_or_IP&amp;gt;/todo_list.php
&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%2Fvorfctxc9jm0v8n1k1et.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%2Fvorfctxc9jm0v8n1k1et.PNG" alt="Lempstack" width="800" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations!&lt;/p&gt;

&lt;p&gt;In this guide, we've successfully established a versatile foundation for serving PHP websites and applications to our visitors. &lt;/p&gt;

&lt;p&gt;Utilizing Nginx as the web server and MySQL as the database management system, we've created a robust environment ready to connect and interact seamlessly. Well done!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>devops</category>
      <category>beginners</category>
      <category>aws</category>
    </item>
    <item>
      <title>Harnessing the Power of AWS: Building a LAMP Stack Web Server for Your Website</title>
      <dc:creator>Matthew M Tarfa</dc:creator>
      <pubDate>Wed, 21 Feb 2024 14:23:15 +0000</pubDate>
      <link>https://dev.to/cloudforce/harnessing-the-power-of-aws-building-a-lamp-stack-web-server-for-your-website-2fnf</link>
      <guid>https://dev.to/cloudforce/harnessing-the-power-of-aws-building-a-lamp-stack-web-server-for-your-website-2fnf</guid>
      <description>&lt;p&gt;A technology stack is a thoughtfully assembled software tools, programming languages, frameworks, and libraries which are meticulously selected to collaboratively contribute to the development and maintenance of a well-functioning software. These stacks are often represented by acronyms, encapsulating the specific technologies harmoniously utilized in the creation of a tailored technology product. Some examples are.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;LAMP (Linux, Apache, MySQL, PHP or Python, or Perl)&lt;/li&gt;
&lt;li&gt;LEMP (Linux, Nginx, MySQL, PHP or Python, or Perl)&lt;/li&gt;
&lt;li&gt;MERN (MongoDB, ExpressJS, ReactJS, NodeJS)&lt;/li&gt;
&lt;li&gt;MEAN (MongoDB, ExpressJS, AngularJS, NodeJS)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this blog, we'll guide you through the process of setting up a LAMP stack web server on the Amazon Web Services (AWS) platform, empowering you to deploy and host your web applications seamlessly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Launch an AWS EC2 Instance
&lt;/h3&gt;

&lt;p&gt;To complete this project its expected that you already have an Amazon Account and know how to create an EC2 instance if you dont here is a link where you can learn this.&lt;br&gt;
&lt;a href="https://dev.to/cloudforce/getting-started-with-ec2-a-beginners-guide-to-launching-your-first-cloud-instance-23cg"&gt;https://dev.to/cloudforce/getting-started-with-ec2-a-beginners-guide-to-launching-your-first-cloud-instance-23cg&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: Configure Security Groups
&lt;/h3&gt;

&lt;p&gt;When creating your EC2 instance, ensure to configure security groups to allow traffic on necessary ports. Open ports 22 (SSH), 80 (HTTP), and 443 (HTTPS) to enable remote access and web traffic.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Connect to Your EC2 Instance
&lt;/h3&gt;

&lt;p&gt;Once your instance is running, connect to it using SSH. You can use You can use a tool like PuTTY on Windows or the terminal on Linux/Mac.i would be using Git Bash. Also ensure that you have the private key corresponding to the key pair selected during instance creation.you will change directory (cd) to the directory where you saved the key, this will enable you SSH into the instance successfully. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connect to the instance by running
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -i &amp;lt;private-key-name&amp;gt;.pem ubuntu@&amp;lt;Public-IP-address&amp;gt;
&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%2Fmi5ly1qdejm7fkmf7olh.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%2Fmi5ly1qdejm7fkmf7olh.PNG" alt="picture1" width="697" height="729"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 4: Update Packages and Firewall
&lt;/h3&gt;

&lt;p&gt;Update the package list installed on your instance using the below 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 apt update
&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%2Frn5l2xu96nykzixuv8us.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%2Frn5l2xu96nykzixuv8us.PNG" alt="pic2" width="800" height="668"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Step 5: Install Apache2 Web Server
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;What exactly is Apache?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Apache is an open-source web server software widely used for hosting websites and applications, it is free. It runs in no less than 65% of the worlds servers. Its modular architecture, cross-platform compatibility, and community support make it a popular choice for serving web content. Apache's features include virtual hosting, security measures, and flexibility through customizable modules.&lt;/p&gt;

&lt;p&gt;Install Apache using Ubuntu’s package manager ‘apt’:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#run apache2 package installation
sudo apt install apache2
&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%2Fqoly2qynej2tzb6cgi8x.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%2Fqoly2qynej2tzb6cgi8x.PNG" alt="pic3" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To verify that apache2 is running as a Service in our OS, use following command&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;sudo systemctl status apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If its green and running then we did everything correctly.&lt;/li&gt;
&lt;/ul&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%2Fn7pkxfkwdmh356h6sa65.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%2Fn7pkxfkwdmh356h6sa65.PNG" alt="pic3a" width="754" height="331"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can also check our apache2 server locally in our ubuntu shell using the below command.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl http://localhost:80
or
 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/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnswq22jiimxzhls2lk2m.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%2Fnswq22jiimxzhls2lk2m.PNG" alt="pic3b" width="800" height="644"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can also test how our Apache HTTP server can respond to requests from the Internet.
Open a web browser of your choice and try to access following url
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://&amp;lt;Public-IP-Address&amp;gt;:80
&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%2Ftt7dc398pgnfkh7xlai3.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%2Ftt7dc398pgnfkh7xlai3.PNG" alt="apache defualt page" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Install MySQL Database Server
&lt;/h3&gt;

&lt;p&gt;MySQL is a widely used relational database management system (RDBMS) commonly employed in PHP environments. It facilitates the storage, retrieval, and management of structured data, playing a pivotal role in web application development. Known for its speed, reliability, and ease of integration with PHP, MySQL is a preferred choice for many developers building dynamic and data-driven websites.&lt;/p&gt;

&lt;p&gt;Again, use ‘apt’ to acquire and install this software:&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;&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%2Fpiy0rhxu9aob9udrqh2q.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%2Fpiy0rhxu9aob9udrqh2q.PNG" alt="pic5" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Confirm installation with 'Y' when prompted and press ENTER. After installation, log in to the MySQL console by typing:&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;&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%2Fg1rmw44i1ge42001gdyz.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%2Fg1rmw44i1ge42001gdyz.PNG" alt="pic6" width="611" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Exit the MySQL shell with:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;After installing MySQL, enhance security using the built-in script:&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;p&gt;Configure the VALIDATE PASSWORD PLUGIN, choose a policy level, and set a corresponding new password. Confirm changes by selecting 'Y' and pressing Enter to remove anonymous users, disable remote root logins, and apply new rules for immediate effect.&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%2Fkhrkfddf98eujbri0876.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%2Fkhrkfddf98eujbri0876.PNG" alt="pic7" width="800" height="615"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the password phase skipped then you would have to use the ALTER USER to set the password for the root user.&lt;/p&gt;

&lt;p&gt;run 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;$ sudo mysql -p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the -p flag in this command, which will prompt you for the password used after changing the root user password.&lt;br&gt;
and since you were unable to set a pass word initially press enter.&lt;/p&gt;

&lt;p&gt;Now run this command in mysql shell&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 'PassWord1';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;change password1 to your desired password ensuring the password meets the required password standard you have selected earlier.&lt;/p&gt;

&lt;p&gt;Exit the MySQL shell with:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Now, you have successfully set a password for the root user using the MySQL shell.&lt;/p&gt;

&lt;p&gt;run this command input your new pass word and you are in.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql -u root -p
&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%2F7o193dhcr3p38vnrig96.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%2F7o193dhcr3p38vnrig96.PNG" alt="pic8" width="616" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7: Install PHP and Required Modules
&lt;/h3&gt;

&lt;p&gt;Apache serves content, MySQL manages data, and PHP processes code for dynamic content display in our setup.&lt;/p&gt;

&lt;p&gt;Besides the php package,we will install php-mysql for PHP and MySQL communication and libapache2-mod-php to enable Apache to handle PHP files. Core PHP packages will be automatically installed as dependencies.&lt;/p&gt;

&lt;p&gt;To install these 3 packages at once, 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 apt install php libapache2-mod-php php-mysql
&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%2Frrm7ltl3jncn81orii9a.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%2Frrm7ltl3jncn81orii9a.PNG" alt="pic11" width="800" height="574"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the installation is finished, you can run the following command to confirm your PHP version:&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;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%2Fgxkqso2zfvdnj9zy36mv.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%2Fgxkqso2zfvdnj9zy36mv.PNG" alt="pic12" width="569" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point the LAMP stack is now fully installed and operational with Ubuntu Linux, Apache HTTP Server, MySQL, and PHP components successfully integrated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We would take this a notch higher.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 8: Creating a Virtual Host for my Website using Apache
&lt;/h3&gt;

&lt;p&gt;On Ubuntu 20.04, Apache comes with one default server block serving content from /var/www/html. To set up a virtual host, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a directory named "lampstackproject" for your domain with the command:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Assign ownership of the directory using the $USER environment variable to reference the current system user:
&lt;/li&gt;
&lt;/ul&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/lampstackproject
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create and open a new configuration file in Apache's sites-available directory using:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Paste the desired configurations into the opened file.
&lt;/li&gt;
&lt;/ul&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;&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%2Fbsqnvab04z87vbb3zoe8.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%2Fbsqnvab04z87vbb3zoe8.PNG" alt="pic16" width="800" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Save and exit by pressing the "Ctrl + O " key, press "enter", and then pressing the "Ctrl + X " then press "Enter" key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enable the new virtual host with the command: $ sudo a2ensite projectlamp&lt;/p&gt;

&lt;p&gt;Disable the default website installed with Apache using: $ sudo a2dissite 000-default&lt;/p&gt;

&lt;p&gt;Ensure there are no errors in the configuration by running: $ sudo apache2ctl configtest&lt;/p&gt;

&lt;p&gt;Reload Apache to apply the changes with the command: $ sudo systemctl reload apache2&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%2F6w19je62v64as2fsubje.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%2F6w19je62v64as2fsubje.PNG" alt="pic19" width="684" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create an index.html file in your domain directory to test the virtual host with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; $ sudo bash -c "echo -e 'Hello LAMP from hostname\n&amp;lt;h2&amp;gt;MATTHEW Cloud Force&amp;lt;/h2&amp;gt;\n&amp;lt;h3&amp;gt;It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change.&amp;lt;/h3&amp;gt;' &amp;gt; /var/www/lampstackproject/index.html"
&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%2Fla551jy9osa0nehpq54l.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%2Fla551jy9osa0nehpq54l.PNG" alt="pic24" width="800" height="73"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To test if your virtual host is working as expected, you can open your web browser and enter your server's IP address. In this case, it would be the public IP address of your AWS instance.&lt;/p&gt;

&lt;p&gt;If everything is set up correctly, you should see the content you added to the index.html file, including the formatted text and headings.&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%2Fbhhmp6zblx0mid2114j0.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%2Fbhhmp6zblx0mid2114j0.PNG" alt="pic20" width="800" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  STEP 9: Enabling PHP on the website
&lt;/h3&gt;

&lt;p&gt;The default DirectoryIndex settings on Apache prioritize index.html over index.php. This feature is beneficial for creating temporary maintenance pages in PHP applications. &lt;/p&gt;

&lt;p&gt;By crafting a brief message in a temporary index.html file, it takes precedence over index.php, serving as the landing page during maintenance. &lt;/p&gt;

&lt;p&gt;After completing the maintenance, the index.html can be renamed or removed from the document root, restoring the regular application page.&lt;/p&gt;

&lt;p&gt;If you wish to modify this behavior, you must edit the /etc/apache2/mods-enabled/dir.conf file and adjust the order of the index.php file within the DirectoryIndex directive.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /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;
        #Change this:
        #DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
        #To this:
        DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
&amp;lt;/IfModule&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Upon saving and closing the file, it is necessary to reload Apache for the modifications to become effective:
&lt;/li&gt;
&lt;/ul&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;ul&gt;
&lt;li&gt;create an index.php file and add a PHP script to test the installation and configuration of PHP on your server
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano /var/www/projectlamp/index.php
&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%2F9tewxiehwxp9pkrk6tix.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%2F9tewxiehwxp9pkrk6tix.PNG" alt="pic21" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This will open a blank file. Add the following text, which is valid PHP code, inside the file:
&lt;/li&gt;
&lt;/ul&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;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%2Fq64bgv2xr2mot606fmw5.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%2Fq64bgv2xr2mot606fmw5.PNG" alt="pic22" width="800" height="140"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you've made the changes, save and close the file. Afterward, refresh the page in your web browser, and you should observe a page resembling this:&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%2Fskgsnoamd3ju1nd78xo8.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%2Fskgsnoamd3ju1nd78xo8.PNG" alt="pic23" width="800" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remove the PHP file as it contains sensitive information, use 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;sudo rm /var/www/lampstackproject/index.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command deletes the index.php file from the specified directory.&lt;/p&gt;

&lt;p&gt;Congratulations! You've successfully completed a real-life project by deploying a LAMP stack website in the AWS Cloud! This achievement not only demonstrates your technical prowess but also sets the stage for hosting and deploying dynamic web applications. As you continue, consider expanding your server's capabilities, fortifying its security, and confidently deploying future web projects. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;May the Cloud Force Be with you!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>learning</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Transforming Organizations The Power of DevOps Excellence</title>
      <dc:creator>Matthew M Tarfa</dc:creator>
      <pubDate>Tue, 20 Feb 2024 12:26:49 +0000</pubDate>
      <link>https://dev.to/cloudforce/transforming-organizations-the-power-of-devops-excellence-5dgm</link>
      <guid>https://dev.to/cloudforce/transforming-organizations-the-power-of-devops-excellence-5dgm</guid>
      <description>&lt;p&gt;In the rapidly evolving landscape of technology, DevOps stands out as a revolutionary force, reshaping how organizations approach application delivery. Beyond a set of practices, DevOps embodies a cultural transformation that prioritizes collaboration, automation, and continuous improvement. In this blog, we explore the essence of DevOps and elucidate why it is not a fleeting trend but an essential strategy for organizations seeking agility and excellence.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaking Down the Basics of DevOps: A Cultural and Practical Evolution.
&lt;/h2&gt;

&lt;p&gt;At its core, DevOps transcends mere methodology; it embodies a cultural shift that amplifies the entire application delivery spectrum. Picture a synchronized ballet where automation, meticulous quality assurance, perpetual monitoring, testing and collaborative efforts converge to create a symphony of precision, efficiency and dependability.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Rise of Automation: A Departure from Manual Prowess
&lt;/h2&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%2Fcwh3hmbf3510u6d3sljs.JPG" 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%2Fcwh3hmbf3510u6d3sljs.JPG" alt="motivational picture" width="750" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Reflecting on the past, the manual intricacies of application delivery were akin to a slow waltz, prolonging the delivery timelines. DevOps, however, introduces a dynamic and swift tango, embracing change and innovation, now Automation rules! &lt;/p&gt;

&lt;p&gt;This metamorphosis signifies not just a progression but a leap into a realm where efficiency and reliability coalesce seamlessly.&lt;/p&gt;

&lt;p&gt;In this era of rapid technological advancement, the DevOps symphony emerges as the avant-garde, shaping a new narrative for organizations seeking excellence in application delivery. &lt;/p&gt;

&lt;p&gt;The evolution is not merely a response to change; it is a deliberate and strategic stride where efficiency, reliability, and innovation take center stage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Driving Innovation: The Key Tenets of DevOps
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Efficiency Enhancement:&lt;/strong&gt; DevOps propels organizations towards efficiency by automating workflows, eliminating manual tasks, and expediting development cycles, resulting in a more rapid and dependable software delivery.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collaboration Augmentation:&lt;/strong&gt; Breaking down silos, DevOps fosters collaboration between development and operations teams, enriching communication, understanding, and overall alignment to create a cohesive working environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Continuous Delivery and Deployment:&lt;/strong&gt; Embracing continuous integration and continuous delivery (CI/CD), DevOps empowers organizations to release software updates swiftly, enhancing the agility of development teams and ensuring consistent deployment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Quality Assurance:&lt;/strong&gt; DevOps places a premium on continuous testing and quality assurance throughout the development lifecycle, yielding higher-quality software, reducing defects, and safeguarding against issues reaching production.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Customer Satisfaction:&lt;/strong&gt; Swift delivery of features and bug fixes enables organizations to meet and exceed customer expectations, responding promptly to market demands and fostering increased customer satisfaction.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Risk Mitigation:&lt;/strong&gt; Through automated testing and continuous monitoring, DevOps identifies and addresses issues early in the development process, proactively minimizing the risk of major defects or failures in production.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Innovation and Flexibility:&lt;/strong&gt; DevOps nurtures a culture of experimentation and innovation, empowering teams to explore new ideas and technologies, fostering a continuous improvement mindset and adaptability to changing business needs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cost Optimization:&lt;/strong&gt; The automation and efficiency gains achieved through DevOps translate into tangible cost savings by minimizing manual processes and downtime, optimizing resource utilization, and achieving operational cost efficiencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Employee Engagement and Retention:&lt;/strong&gt; DevOps cultivates a collaborative and inclusive work environment, instilling a sense of ownership and achievement among team members, contributing to higher employee satisfaction and retention.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Competitive Edge:&lt;/strong&gt; Organizations embracing DevOps gain a strategic advantage by responding swiftly to market changes. The ability to deliver high-quality software faster becomes a defining factor in today's competitive business landscape.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion: Embrace DevOps, Propel Excellence
&lt;/h2&gt;

&lt;p&gt;DevOps transcends a set of practices; it embodies a cultural and practical evolution propelling organizations towards excellence. &lt;/p&gt;

&lt;p&gt;By championing collaboration, automation, quality and continuous improvement, DevOps emerges not as a transient trend but as an essential strategy for organizations aspiring to thrive in the dynamic digital era. &lt;/p&gt;

&lt;p&gt;The journey towards DevOps excellence is not just a choice; it is a definitive step towards a future where agility, innovation, and reliability converge, propelling organizations to unparalleled heights.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Getting Started with EC2: A Beginner's Guide to Launching Your First Cloud Instance.</title>
      <dc:creator>Matthew M Tarfa</dc:creator>
      <pubDate>Tue, 20 Feb 2024 08:47:34 +0000</pubDate>
      <link>https://dev.to/cloudforce/getting-started-with-ec2-a-beginners-guide-to-launching-your-first-cloud-instance-23cg</link>
      <guid>https://dev.to/cloudforce/getting-started-with-ec2-a-beginners-guide-to-launching-your-first-cloud-instance-23cg</guid>
      <description>&lt;p&gt;Amazon Elastic Compute Cloud (EC2) is a highly scalable and versatile cloud computing service provided by Amazon Web Services (AWS). EC2 allows you to launch and manage virtual servers, known as instances, in the AWS cloud. In this blog post, we will walk you through the step-by-step process of creating an EC2 instance, enabling you to set up and configure your own virtual server within the AWS ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites:
&lt;/h2&gt;

&lt;p&gt;Before we begin, ensure that you have the following prerequisites:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An active AWS account.&lt;/li&gt;
&lt;li&gt;Familiarity with the AWS Management Console.&lt;/li&gt;
&lt;li&gt;Basic understanding of networking concepts and security groups.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Accessing the EC2 Dashboard:
&lt;/h2&gt;

&lt;p&gt;Log in to the AWS Management Console.&lt;br&gt;
Navigate to the EC2 service by clicking on "Services" and selecting "EC2" from the list of services or you could type EC2 in the search bar, here select EC2 from the options provided.&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%2F8nsyr042wv37znhjsydu.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%2F8nsyr042wv37znhjsydu.png" alt="AWS ec2 creation page" width="800" height="339"&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%2F0ep1anwwd0qzlge9cpt4.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%2F0ep1anwwd0qzlge9cpt4.png" alt="AWS EC2 creation 2nd stage" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the EC2 dashboard, click the "Launch Instance" button to initiate the instance creation process.&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%2Fjfqxrjuol52rc0hzie73.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%2Fjfqxrjuol52rc0hzie73.png" alt="AWS EC2 creation 3rd stage" width="800" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give your EC2 a name, give it a unique name to help you differentiate your instances.&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%2Fu0lfbom1d35zbxcgm3xf.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%2Fu0lfbom1d35zbxcgm3xf.png" alt="AWS EC2 creation 4th stage" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose an Amazon Machine Image (AMI) based on your requirements. This serves as the operating system for your instance, here we have selected Ubuntu under the free tier eligible. &lt;/p&gt;

&lt;p&gt;when you register an account with AWS for the first year you are allowed access to some services for free this is one of those services.&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%2Fjnmkxus1pzil9zu7om4d.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%2Fjnmkxus1pzil9zu7om4d.png" alt="AWS EC2 creation 5th stage" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select an instance type that aligns with your desired computing resources, such as CPU, memory, and storage capacity, for the purpose of writing this blog I would stick to the free tier t2 micro.&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%2Fhqv7mindc44d6qpshjrg.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%2Fhqv7mindc44d6qpshjrg.png" alt="AWS EC2 creation 6th stage" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create New Key Pair :
&lt;/h2&gt;

&lt;p&gt;Select an existing key pair or create a new one. A key pair is necessary to securely access your EC2 instance using Secure Shell (SSH).&lt;/p&gt;

&lt;p&gt;If creating a new key pair, follow the instructions to generate and download the private key file (.pem). Keep this file in a secure location.&lt;/p&gt;

&lt;p&gt;I will be creating a new key pair to demonstrate how it is done.&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%2Fy40e8qjw4fwksmtml0rc.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%2Fy40e8qjw4fwksmtml0rc.png" alt="AWS EC2 creation 7th stage" width="800" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on create new key Pair.&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%2F0rg01uunytznzmwgeutr.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%2F0rg01uunytznzmwgeutr.png" alt="AWS EC2 creation 8th stage" width="800" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, you give your key pair a name, and you select the key pair type.&lt;/p&gt;

&lt;p&gt;In this blog, we would not be going into the details of the difference between the two key pair types available but we would go with the RSA key pair type.&lt;/p&gt;

&lt;p&gt;click on Create key pair to continue, this automatically creates a key pair and downloads a pem file into your downloads.&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%2Fjtnekt0912dt31tq99oi.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%2Fjtnekt0912dt31tq99oi.png" alt="AWS EC2 creation 9th stage" width="800" height="547"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We now have a key pair.&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%2Frisidmd8s8dgi9nklltw.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%2Frisidmd8s8dgi9nklltw.png" alt="AWS EC2 creation 10th stage" width="800" height="260"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Network Setting:
&lt;/h2&gt;

&lt;p&gt;Network Settings for this blog we would leave it as the default, AWS provides every account on the AWS platform with default VPC settings so we would work with that.&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%2Fo2806q4nt4ipop8cuf8r.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%2Fo2806q4nt4ipop8cuf8r.png" alt="AWS EC2 creation 11th stage" width="800" height="291"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure Security group(firewall)
&lt;/h2&gt;

&lt;p&gt;Configure security groups to control inbound and outbound traffic for your instance.&lt;/p&gt;

&lt;p&gt;We would create a new security group for this EC3 instance we are creating&lt;/p&gt;

&lt;p&gt;we would allow port 22 which allows secured traffic via SSH also HTTPS connections which use TCP port 443 and HTTP, the unsecured protocol, uses port 80 these are all inbound rules.&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%2F1dnod6ft5rd0ssp4n3xj.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%2F1dnod6ft5rd0ssp4n3xj.png" alt="AWS EC2 creation 12th stage" width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Other Configurations :
&lt;/h2&gt;

&lt;p&gt;We would go ahead to configure other instance details, including the number of instances, and storage options. for the purpose of this blog, we would leave the number of instances at one and for the storage option, we would also leave it as default.&lt;/p&gt;

&lt;p&gt;Review the instance configuration and make any necessary adjustments.&lt;/p&gt;

&lt;p&gt;If creating a new key pair, follow the instructions to generate and download the private key file (.pem). Keep this file in a secure location.&lt;/p&gt;

&lt;p&gt;Once you have reviewed the instance details, click "Launch" to initiate the creation of your EC2 instance.&lt;/p&gt;

&lt;h2&gt;
  
  
  EC2 Dashboard:
&lt;/h2&gt;

&lt;p&gt;The instance creation process will commence. You can monitor the progress and view the instance status on the EC2 dashboard.&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%2Fr3h79bu1b3h1sn3s2ycu.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%2Fr3h79bu1b3h1sn3s2ycu.png" alt="AWS EC2 creation 13th stage" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After initialization, you check if your instance is healthy by confirming that you have 2/2 checked and passed.&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%2Fc59kyhyuyvmo27cs9dez.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%2Fc59kyhyuyvmo27cs9dez.png" alt="AWS EC2 creation final stage" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;Congratulations! You have successfully created an EC2 instance on AWS. &lt;/p&gt;

&lt;p&gt;By following the comprehensive steps outlined in this guide, you have gained the knowledge to launch and configure your own virtual server within the AWS cloud. &lt;/p&gt;

&lt;p&gt;Remember to monitor and manage your instances using the EC2 dashboard, and explore additional AWS services to enhance the functionality and scalability of your EC2 instances.&lt;/p&gt;

&lt;p&gt;We hope this comprehensive guide has provided you with a clear understanding of the process involved in creating an AWS EC2 instance. &lt;/p&gt;

&lt;p&gt;Embrace the power of EC2 to meet your computing requirements in the cloud, and unlock the potential of AWS for your business needs. Happy cloud computing!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>devops</category>
      <category>aws</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
