<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Leshan Sanjeewa on Medium]]></title>
        <description><![CDATA[Stories by Leshan Sanjeewa on Medium]]></description>
        <link>https://medium.com/@leshaan99?source=rss-64f91930c1c4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RgXUM0Sd47T87DsGBjljmg.png</url>
            <title>Stories by Leshan Sanjeewa on Medium</title>
            <link>https://medium.com/@leshaan99?source=rss-64f91930c1c4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:27:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leshaan99/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Install and Run Prometheus — Step by Step Guide]]></title>
            <link>https://medium.com/@leshaan99/how-to-install-and-run-prometheus-step-by-step-guide-eda31b643451?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/eda31b643451</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Fri, 11 Jul 2025 08:28:42 GMT</pubDate>
            <atom:updated>2025-07-11T08:28:42.329Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Install and Run Prometheus — Step by Step Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEcGzX3e-GjiQUI85gC8pQ.png" /></figure><p>Prometheus is a powerful open source systems monitoring and alerting toolkit. In this guide, we’ll install Prometheus on a Linux system, configure it properly, and run it as a systemd service so it can start on boot and run in the background.</p><p><strong>Prepare Linux System</strong></p><p>Before installing Prometheus, let’s make sure system is up to date and has essential tools installed.</p><pre>sudo apt update &amp;&amp; sudo apt upgrade -y</pre><p>Then install required dependencies like wget and tar (usually preinstalled on most systems, but just in case)</p><pre>sudo apt install wget tar -y</pre><p><strong>Download Prometheus</strong></p><p>Head over to the <a href="https://prometheus.io/download/">official Prometheus downloads page</a> and download the latest Linux AMD64 version.</p><p>Or use wget to download directly</p><pre>wget https://github.com/prometheus/prometheus/releases/download/v2.37.0/prometheus-2.37.0.linux-amd64.tar.gz</pre><p><strong>Extract the Archive</strong></p><p>Unpack the tarball using</p><pre>tar xvf prometheus-2.37.0.linux-amd64.tar.gz</pre><p>Flags explained</p><ul><li>x: extract</li><li>v: verbose (show file names)</li><li>f: file (followed by the archive name)</li></ul><p><strong>Test Prometheus Binary</strong></p><p>Navigate to the extracted folder and start Prometheus manually.</p><pre>cd prometheus-2.37.0.linux-amd64/<br>./prometheus</pre><p>Visit <a href="http://localhost:9090/">http://localhost:9090</a> in browser. If the UI loads without errors, Prometheus is working correctly.</p><p><strong>Create a Dedicated Prometheus User</strong></p><p>To improve security, create a non login user for Prometheus.</p><pre>sudo useradd - no-create-home - shell /bin/false prometheus</pre><p>Flags explained</p><ul><li>-no-create-home: Do not create a home directory for the user.</li><li>-shell /bin/false: Set the login shell to /bin/false, so the user cannot log in.</li></ul><p>This ensures Prometheus runs as a limited user, not root.</p><p><strong>Create Required Directories</strong></p><p>Create directories for configuration and time-series data.</p><pre>sudo mkdir /etc/prometheus<br>sudo mkdir /var/lib/prometheus</pre><p>/etc/prometheus - stores configuration files<br> /var/lib/Prometheus - stores time-series database (TSDB) files</p><p><strong>Set Ownership for Directories</strong></p><p>Assign ownership to the prometheus user and group.</p><pre>sudo chown prometheus:prometheus /etc/prometheus<br>sudo chown prometheus:prometheus /var/lib/prometheus</pre><p><strong>Move Binaries to System Path</strong></p><p>Copy Prometheus executables to /usr/local/bin/</p><pre>sudo cp prometheus /usr/local/bin/<br>sudo cp promtool /usr/local/bin/</pre><p>Set proper ownership</p><pre>sudo chown prometheus:prometheus /usr/local/bin/prometheus<br>sudo chown prometheus:prometheus /usr/local/bin/promtool</pre><p><strong>Copy Console Files</strong></p><p>These are used for Prometheus’s web UI.</p><pre>sudo cp -r consoles /etc/prometheus<br>sudo cp -r console_libraries /etc/Prometheus</pre><p>Set permissions</p><pre>sudo chown -R prometheus:prometheus /etc/prometheus/consoles<br>sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries</pre><p><strong>Add Prometheus Configuration</strong></p><p>Copy the default prometheus.yml configuration file give the ownership.</p><pre>sudo cp prometheus.yml /etc/prometheus/prometheus.yml<br>sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml</pre><p><strong>Run Prometheus with Configuration</strong></p><p>Now can run Prometheus with all paths set</p><pre>sudo -u prometheus /usr/local/bin/prometheus \<br> - config.file=/etc/prometheus/prometheus.yml \<br> - storage.tsdb.path=/var/lib/prometheus/ \<br> - web.console.templates=/etc/prometheus/consoles \<br> - web.console.libraries=/etc/prometheus/console_libraries</pre><p><strong>Create a Systemd Service</strong></p><p>Create a systemd unit file for Prometheus</p><pre>sudo vi /etc/systemd/system/prometheus.service</pre><p>Paste the following content</p><pre>[Unit]<br>Description=Prometheus<br>Wants=network-online.target<br>After=network-online.target<br>[Service]<br>User=prometheus<br>Group=prometheus<br>Type=simple<br>ExecStart=/usr/local/bin/prometheus \<br> - config.file=/etc/prometheus/prometheus.yml \<br> - storage.tsdb.path=/var/lib/prometheus/ \<br> - web.console.templates=/etc/prometheus/consoles \<br> - web.console.libraries=/etc/prometheus/console_libraries<br>[Install]<br>WantedBy=multi-user.target</pre><p><strong>Reload Systemd and Start Prometheus</strong></p><pre>sudo systemctl daemon-reload<br>sudo systemctl start prometheus</pre><p>Check the service status.</p><pre>sudo systemctl status prometheus</pre><p>Status should show as active (running)</p><p><strong>Enable on Boot</strong></p><p>Make Prometheus start automatically on boot</p><pre>sudo systemctl enable prometheus</pre><p>Can verify with</p><pre>sudo systemctl status prometheus</pre><p>Look for: Enabled; vendor preset: enabled</p><p>Now have a fully functional Prometheus instance running on Linux system as a background service.</p><p>Can visit it at <a href="http://localhost:9090/">http://localhost:9090</a> to explore the web interface, run queries, and start building monitoring dashboards.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eda31b643451" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy React App to AWS EC2 Using CI/CD Pipeline]]></title>
            <link>https://medium.com/@leshaan99/github-actions-deploy-react-app-to-aws-ec2-ci-cd-pipeline-51001a7a01ec?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/51001a7a01ec</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 04:43:06 GMT</pubDate>
            <atom:updated>2025-07-10T09:16:37.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bhyFoFrLvlFRr7HK8OVFew.png" /></figure><p>In the world of modern software development, automating deployment processes and ensuring seamless integration and delivery is paramount. In this tutorial, we’ll guide you through setting up an automated deployment pipeline for a react application on docker hub using github actions. We’ll cover everything from configuring a ci/cd workflow to building and testing your react application, containerizing it with docker, and deploying it to docker hub, ensuring your app is always up-to-date and ready for production with ease.</p><p><strong>1.Setting Up EC2 Instance</strong></p><p>To deploy your React app, you’ll need to launch and set up an Amazon EC2 instance. Follow these steps to create an EC2 instance and configure it to host your app.</p><p>Launch a New EC2 Instance</p><ul><li>In the EC2 Dashboard, click the <strong>Launch Instance</strong> button and give the instance name.</li><li>Choose an Amazon Machine Image (AMI) Select <strong>Ubuntu Server 20.04 LTS</strong> as the operating system.</li><li>Choose an Instance Type Select <strong>t3.micro</strong> (eligible for the free tier).</li><li>Click Create new key pair and set the key pair name. Keep Key pair type as <strong>RSA </strong>and file format as <strong>.pem</strong>. After that settings click Create key pair.</li><li>Review the details and click Launch.</li></ul><p>Connect EC2 Instance</p><ul><li>Once your instance is running, select it from the EC2 Dashboard. Click <strong>Connect</strong> to get connection instructions.</li><li>Select EC2 Instance Connect to connect to your instance. Click connect and then command line open with the new browser tab.</li></ul><p>Installing Docker on Ubuntu EC2 Instance</p><pre># Update the package list<br>sudo apt-get update<br><br># Install Docker<br>sudo apt-get install docker.io -y<br><br># Start the Docker service<br>sudo systemctl start docker<br><br># Enable Docker to start on boot<br>sudo systemctl enable docker<br><br># Give permissions to this file<br>sudo chmod 666 /var/run/docker.sock<br><br># Verify Docker installation<br>docker –version<br><br># Test Docker with the hello-world container<br>docker run hello-world</pre><p>This will pull and run a test image to ensure Docker is installed correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ivSMP-J_9jAr1y3wg7Hj3w.png" /><figcaption>correctly install docker in the ce2 instance</figcaption></figure><p>ensure that your EC2 instance’s security group allows inbound traffic on the port you exposed,</p><ul><li>Go to the EC2 dashboard in the AWS Management Console.</li><li>Select your instance and click on <strong>Security Groups</strong> in the description tab.</li><li>Click on the relevant security group, then go to the <strong>Inbound rules</strong> tab and ensure there is a rule to allow HTTP traffic:</li><li>Type:<strong> HTTP</strong></li><li>Protocol: <strong>TCP</strong></li><li>Port range: <strong>3000</strong></li><li>Source: <strong>0.0.0.0/0</strong> (to allow traffic from anywhere)</li></ul><p><strong>2.Dockerizing the React App</strong></p><p>After setting up Docker on your EC2 instance, the next step is to create a Dockerfile that defines the environment in which your React app will run. Below is the Dockerfile you’ll use for your React project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3abb1ab53bc493d8bf70c7e7b22620d6/href">https://medium.com/media/3abb1ab53bc493d8bf70c7e7b22620d6/href</a></iframe><p><strong>3.Build and Run Docker Image</strong></p><p>Once the Dockerfile is created, you can build the Docker image for your React app and run it on the EC2 instance.</p><p>Use the following command to build the Docker image from the Dockerfile. Make sure you’re in the root directory of your React project (where the Dockerfile is located).</p><pre>docker build -t counter-app .</pre><p>After building the Docker image, you can run the container with the following command:</p><pre>docker run -p 3000:3000 counter -app</pre><p>This maps port 3000 on your EC2 instance to port 3000 inside the container, allowing you to access the React app via the EC2 instance’s public IP.</p><p><strong>4.Set Up The Github Workflow Folder And A Basic Workflow For The Project</strong></p><p>Create the GitHub Workflow Folder</p><p>To set up GitHub Actions, you need to create a folder in your repository that holds your workflow configuration files. In your project root directory, create the following directory structure</p><pre>.github/workflows/</pre><p>Make sure that your GitHub repository has all the project files directly in the root, not inside a subfolder.</p><p>When you initialize your GitHub repository, make sure that the structure looks like this in the root of the repo.</p><pre>.github/<br>workflows/<br>Dockerfile<br>package.json<br>package-lock.json<br>src/<br>public/<br>README.md</pre><p>Inside the workflows folder, you’ll add your workflow YAML file that defines the pipeline for building the Docker image and deploying it.</p><p>Create ci-cd.yml File in the Workflows Folder</p><p>Inside the workflows folder, create a new file called ci-cd.yml. This file will contain the GitHub Actions workflow configuration for your CI/CD pipeline.</p><p>This file sets up GitHub Actions to automatically.</p><ul><li><strong>Build your React app.</strong></li><li><strong>Push the Docker image to Docker Hub.</strong></li><li><strong>Deploy the image to an AWS EC2 instance.</strong></li></ul><p>Add the following secrets to your GitHub repository.</p><ul><li>Click on the <strong>Settings</strong> tab in your repository.</li><li>In the left sidebar, click on <strong>Secrets and variables</strong>.</li><li>Click the <strong>New repository secret</strong> button.</li><li>Enter Secret Name and Value</li></ul><p>DOCKER_HUB_USERNAME: Your Docker Hub username.</p><p>DOCKER_HUB_PASSWORD: Your Docker Hub password.</p><p><strong>Here are the steps to build a React app and push it to Docker Hub.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d0704e7100de05a24dea12800266cad/href">https://medium.com/media/0d0704e7100de05a24dea12800266cad/href</a></iframe><p><strong>Here are the steps to deploy a Docker image to an EC2 instance.</strong></p><p>Creating a Self-Hosted Runner on AWS EC2 for GitHub Actions</p><ul><li>Go to your GitHub repository.</li><li>Navigate to <strong>Settings</strong> &gt; <strong>Actions</strong> &gt; <strong>Runners</strong> and click on <strong>Add runner</strong>.</li><li>Choose the Linux runner image and copy the provided commands for downloading the runner.</li><li>Execute the <strong>copied commands</strong> in your EC2 terminal to download, configure, and run the runner.</li><li>After setting up, click on the <strong>Actions tab</strong> in your GitHub repository.</li><li>Check the Runners section,you should see a green status symbol indicating that your runner is active.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e306a2f3c3a7848aba3bc9bb41924cc/href">https://medium.com/media/0e306a2f3c3a7848aba3bc9bb41924cc/href</a></iframe><p>Once the workflow is in place, push your code to GitHub. The CI/CD pipeline will,</p><ol><li><strong>Build the React app.</strong></li><li><strong>Containerize it using Docker.</strong></li><li><strong>Push the Docker image to Docker Hub.</strong></li><li><strong>Deploy the Docker image to the EC2 instance.</strong></li></ol><p>Open a web browser and enter the public IP of your EC2 instance</p><p>React application should be up and running!</p><p>This pipeline ensures seamless CI/CD for your React app. Let me know if you need any further adjustments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51001a7a01ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding GitHub Action Job Artifacts and Outputs]]></title>
            <link>https://medium.com/@leshaan99/understanding-job-artifacts-and-outputs-in-github-actions-61159f7f9fad?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/61159f7f9fad</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Fri, 11 Oct 2024 08:45:54 GMT</pubDate>
            <atom:updated>2025-07-10T09:15:41.793Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2FTMiIjuxX8mvXNLiQ7_Q.png" /></figure><p>GitHub Actions provides powerful automation capabilities, enabling you to build CI/CD pipelines. Two key components in GitHub Actions are Job Artifacts and Job Outputs. These concepts allow workflows to share data across different jobs and workflow runs efficiently.</p><p>In this article, we’ll cover</p><ol><li>What are Job Artifacts?</li><li>Uploading Job Artifacts</li><li>Downloading Job Artifacts (Manually and Automatically)</li><li>Understanding Job Outputs</li><li>Using Job Outputs in Other Jobs</li><li>The Need for Dependency Caching</li></ol><p><strong>1. What are Job Artifacts?</strong></p><p>Artifacts in GitHub Actions are files created during a workflow run that you may want to save for future use. These can include build outputs, logs, or test reports. Artifacts help you share data between jobs, which is crucial in workflows where one job’s output is needed in another job, such as for testing.</p><p><strong>2. Uploading Job Artifacts</strong></p><p>To upload an artifact in a GitHub Actions job, you use the actions/upload-artifact action. This uploads files or directories, making them available for subsequent jobs or for manual download after the workflow completes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11283fe34096a6246cede7fa83262506/href">https://medium.com/media/11283fe34096a6246cede7fa83262506/href</a></iframe><p><strong>3. Downloading Job Artifacts</strong></p><p>Artifacts can be downloaded manually or automatically for use in other jobs.</p><p><strong>Manually Downloading Artifacts</strong></p><p>Once a workflow run completes, you can download artifacts manually through the GitHub Actions UI. These are typically available for up to 90 days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o_0OJ1lWrjec6u8qWLHPeA.png" /><figcaption>download artifacts files</figcaption></figure><p><strong>Automatically Downloading Artifacts</strong></p><p>To automatically download artifacts in another job, you can use the actions/download-artifact action. This is particularly useful when you need to pass files from one job to another in the same workflow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d746023654284dc1cb9347aab6c3200/href">https://medium.com/media/9d746023654284dc1cb9347aab6c3200/href</a></iframe><p>To automatically download artifacts uploaded in one job within another job, the jobs must run sequentially rather than in parallel. This is essential because the second job relies on the output of the first job. You can achieve this by using the needs keyword, which ensures that the second job waits for the first job to complete before starting.</p><p><strong>4. Understanding Job Outputs</strong></p><p>Job outputs allow jobs to return data that other jobs in the same workflow can consume. Unlike artifacts, job outputs are small pieces of data (strings, numbers, etc.), which can be passed easily between jobs without needing to upload or download files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a88ea5751e2d7bc42b9281f518648f4c/href">https://medium.com/media/a88ea5751e2d7bc42b9281f518648f4c/href</a></iframe><p><strong>5. Using Job Outputs in Other Jobs</strong></p><p>To use job outputs in another job, you reference them using the needs keyword. The job that requires the output should specify which previous job it depends on, allowing it to access the output value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a0b8850baed4a53c028e7abbb1621b5/href">https://medium.com/media/7a0b8850baed4a53c028e7abbb1621b5/href</a></iframe><p><strong>6. The Need for Dependency Caching</strong></p><p>Dependency caching helps speed up workflows by reusing previously downloaded or built dependencies. Instead of fetching dependencies from external sources or rebuilding files every time a workflow runs, caching allows you to store these dependencies and retrieve them efficiently in subsequent runs.</p><p>GitHub Actions provides actions/cache for dependency caching.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92064bcdb4c48b944c2f913db38221b2/href">https://medium.com/media/92064bcdb4c48b944c2f913db38221b2/href</a></iframe><p><strong>Conclusion</strong></p><p>GitHub Actions provides flexible mechanisms to store and share data between jobs using artifacts, outputs, and caches. Mastering these techniques allows you to create efficient, reliable workflows that minimize redundant work and speed up your development cycle.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61159f7f9fad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Create A Docker File For A Simple React Application]]></title>
            <link>https://medium.com/@leshaan99/docker-how-to-create-a-dockerfile-for-a-simple-react-application-949fcfbe405c?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/949fcfbe405c</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Fri, 26 Jul 2024 11:27:46 GMT</pubDate>
            <atom:updated>2025-07-10T09:19:52.357Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8o0MyhWv2gJfZJiT4GOLYA.png" /></figure><p>Docker is a powerful tool that allows developers to package applications and their dependencies into a container, ensuring consistency across different environments. Let’s see step by step how to Dockerized React application that you can easily deploy anywhere.</p><p><strong>Navigate to Your React Application</strong></p><p>Open your terminal and navigate to the root directory of your existing React application.</p><pre>cd F:\Project\GitHub\Portfolio\portfolio</pre><p><strong>Create a Dockerfile</strong></p><p>In the root directory of React application, create a file named Dockerfile. This file will contain the instructions for building the Docker image.</p><p>Dockerfile Contents</p><pre># Build the React app<br>FROM node:20.11-alpine<br><br># Set working directory<br>WORKDIR /app<br><br># Copy the rest of the application<br>COPY ./ ./<br><br># Install dependencies<br>RUN npm install<br><br># Start npm<br>CMD [&quot;npm&quot;, &quot;start&quot;]</pre><p>· FROM FROM node:20.11-alpine</p><p>Use the official Node.js 20 image based on Alpine Linux.</p><p>· WORKDIR /app</p><p>Set the working directory to /app .</p><p>· COPY ./ ./</p><p>Copy the rest of the application code to the working directory.</p><p>· RUN npm install</p><p>Install the dependencies.</p><p>· CMD [“npm”, “start”]</p><p>Start npm in the foreground.</p><p><strong>Build the Docker image</strong></p><p>Run the following command in the root directory of React application</p><pre>docker build -t portfolio .</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zFikfu-qk-V79x0Et2jeVg.png" /><figcaption><strong>building docker image</strong></figcaption></figure><p>This command will build a Docker image named portfolio using the instructions in the Dockerfile. Make sure that you are open the docker desktop.</p><p><strong>Run the Docker container</strong></p><p>After the image is built, you can run it as a container</p><pre>docker run -p 3000:3000 portfolio</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LfSjyfqOGog0YJGJgO1uig.png" /><figcaption><strong>run docker container</strong></figcaption></figure><p>This command maps port 3000 of your local machine to port 3000 of the container, making your React application accessible at <a href="http://localhost:3000/">http://localhost:3000</a> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*89P_zC59shClDhteaCZjDQ.png" /><figcaption>accsess the localhost in browser</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=949fcfbe405c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Serve Static Files with NGINX — Simple and Effective]]></title>
            <link>https://medium.com/@leshaan99/nginx-how-to-serve-static-content-2268c4272284?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2268c4272284</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Fri, 05 Jul 2024 18:59:54 GMT</pubDate>
            <atom:updated>2025-07-10T09:23:45.155Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Serve Static Files with NGINX — Simple and Effective</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_ixAAbG9o8wHeomw3Rt1A.png" /></figure><p>Nginx is a powerful web server that is widely used for serving static content due to its high performance and ease of configuration. In this, i will walk you through the steps to serve static content, such as HTML, CSS, and image files, using Nginx on an Ubuntu system.</p><p><strong>Start Nginx</strong></p><pre>sudo service nginx start</pre><p>If Nginx isn’t installed on your system. You can install it using the following commands.</p><pre>sudo apt update<br>sudo apt install nginx</pre><p><strong>Prepare Your Static Content</strong></p><p>Create a directory to hold your static files. This directory will contain your HTML, CSS, and image files.</p><pre>mkdir -p /mnt/c/Users/DELL/Desktop/mysite</pre><p>Create a simple HTML file, along with CSS and image files.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;title&gt;Welcome to My Website&lt;/title&gt;<br>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;h1&gt;Hello!, I&#39;m Leshan&lt;/h1&gt;<br>&lt;img src=&quot;image.jpg&quot; alt=&quot;Sample Image&quot;&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>CSS file named style.css in the same directory.</p><pre>body {<br>font-family: Arial, sans-serif;<br>text-align: center;<br>}</pre><p>And place an image file named image.png in the same directory.</p><p><strong>Configure Nginx</strong></p><p>Next, we need to configure Nginx to serve these files. It we have to move Nginx directory.</p><pre>cd etc/nginx/</pre><p>And use this command to open the configuration file via visual studio.</p><pre>Code .</pre><p>Open the nginx.conf file</p><p>Modify the server block to point to your static content directory. Replace the existing location / block with the following configuration.</p><pre>events {<br><br>}<br><br>http {<br>  server {<br>    listen 8080;<br>    server_name localhost;<br><br>    location / {<br>      root /mnt/c/Users/DELL/Desktop/mysite;<br>      index index.html;<br>    }<br>  }<br>}</pre><p><strong>Test the Configuration</strong></p><p>Before reloading Nginx, it’s a good practice to test the configuration for syntax errors. Use below code for that.</p><pre>sudo nginx -t</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UKYaJ2yIHmnqINO5Wh2afQ.png" /><figcaption>result of the configuration file test</figcaption></figure><p><strong>Reload Nginx</strong></p><p>If the configuration test is successful, reload Nginx to apply the changes.</p><pre>nginx -s reload</pre><p><strong>Access Your Static Content</strong></p><p>Open a web browser and navigate to <a href="http://localhost/">http://localhost</a> . You should see your HTML file being served by Nginx, along with the associated CSS and image files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OWxp3sZoHtignBs2fOSqrA.png" /><figcaption>web browser preview</figcaption></figure><p><strong>Multipurpose Internet Mail Extensions(MIME)</strong></p><p>MIME types are used to determine how the server should handle and interpret different types of files it serves to clients (web browsers). By configuring MIME types, you ensure that content is correctly identified and processed.</p><p><strong>Setting MIME Types in Nginx</strong></p><pre>http {<br>  include /etc/nginx/mime.types;<br>}</pre><p>By managing MIME types effectively in Nginx, you ensure that files are served with the correct content type headers, enabling browsers to interpret and display content correctly. This configuration is crucial for delivering web content efficiently and ensuring compatibility across different platforms and devices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2268c4272284" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with NGINX — Easy Installation Guide]]></title>
            <link>https://medium.com/@leshaan99/nginx-how-to-install-nginx-966f81607ed6?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/966f81607ed6</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Tue, 02 Jul 2024 12:32:48 GMT</pubDate>
            <atom:updated>2025-07-10T09:32:33.332Z</atom:updated>
            <content:encoded><![CDATA[<h3>Getting Started with NGINX — Easy Installation Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_ixAAbG9o8wHeomw3Rt1A.png" /></figure><p><strong>How to Install NGINX ?</strong></p><p>Nginx is primarily designed to run on Unix-based systems, but you can still install it on Windows using several methods, such as using the native Windows version or leveraging Windows Subsystem for Linux (WSL).</p><p>Here’s a step-by-step guide on how to install Nginx on both a Windows and an Ubuntu 22.04 LTS system</p><p><strong>Installing Nginx on Windows</strong></p><p>1. Download Nginx</p><p>Visit the <a href="https://nginx.org/en/download.html">https://nginx.org/en/download.html</a> . Download the latest mainline version ZIP file for Windows.</p><p>2. Extract the Downloaded File</p><p>Extract the contents of the ZIP file to a directory. e.g. C:\nginx.</p><p>3. Run Nginx</p><p>· Open Command Prompt as an administrator.</p><p>· Navigate to the Nginx directory.</p><pre>cd C:\nginx</pre><p>· Start Nginx by running</p><pre>start nginx</pre><p>4. Verify Installation</p><p>Open a web browser and navigate to <a href="http://localhost./">http://localhost.</a> You should see the Nginx welcome page.</p><p>· To stop Nginx use</p><pre>nginx -s stop</pre><p>· To restart Nginx use</p><pre>nginx -s reload</pre><p><strong>Installing Nginx on Windows Subsystem for Linux (WSL)</strong></p><p>1. Open the Ubuntu terminal and update the package lists</p><pre>sudo apt update</pre><p>2. Install Nginx</p><pre>sudo apt install nginx</pre><p>3. Start Nginx</p><pre>sudo service nginx start</pre><p>4. Verify Installation</p><p>In your browser, go to <a href="http://localhost/">http://localhost</a> .You should see the Nginx welcome page.</p><p><strong>Installing Nginx on Ubuntu 22.04 LTS</strong></p><ol><li>Open a terminal and run</li></ol><pre>sudo apt update</pre><p>2. Install Nginx with the following command</p><pre>sudo apt install nginx</pre><p>3. Enable the Nginx service to start automatically at boot</p><pre>sudo systemctl enable nginx</pre><p>4. Verify Installation</p><p>Open a web browser and go to <a href="http://localhost./">http://localhost.</a> You should see the Nginx welcome page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-rqaMYLSMq6PGJ0LFhyxhQ.png" /><figcaption>nginx welcome page</figcaption></figure><p>By following these detailed instructions, you should have Nginx installed and configured on both Windows and Ubuntu 22.04 LTS systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=966f81607ed6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding NGINX — The Modern Web Server Explained]]></title>
            <link>https://medium.com/@leshaan99/nginx-what-is-nginx-4bad86ef83ed?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bad86ef83ed</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 11:41:54 GMT</pubDate>
            <atom:updated>2025-07-10T09:33:15.871Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding NGINX — The Modern Web Server Explained</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_ixAAbG9o8wHeomw3Rt1A.png" /></figure><p><strong>What is NGINX ?</strong></p><p>Nginx is a high-performance, open-source web server and reverse proxy server designed for high concurrency, performance, and low memory usage. It has grown to become one of the most popular web servers in the world, often used as a reverse proxy, load balancer, and HTTP cache.</p><p><strong>How NGINX Work ?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFhD9RIZuxY4mcGfLEhwzw.png" /><figcaption>NGINX work as a reverse proxy</figcaption></figure><p>As a reverse proxy, Nginx acts as an intermediary server that sits between clients (like web browsers) and multiple web servers. It directs traffic to the appropriate backend server and relays the response back to the client, making it seem like the content came directly from Nginx.</p><p><strong>Key Features of Nginx</strong></p><p>1. High Performance</p><p>Handles a large number of simultaneous connections with minimal memory usage.</p><p>2. Reverse Proxy and Load Balancing</p><p>Distributes client requests across multiple servers to balance the load and improve reliability.</p><p>3. HTTP Cache</p><p>Stores copies of responses for faster load times on subsequent requests.</p><p>4. SSL/TLS Support</p><p>Provides secure data transmission with SSL/TLS.</p><p>5. Web Server</p><p>Serves static content, such as HTML, CSS, and images, efficiently.</p><p>6. Modular Architecture</p><p>Extensible with modules for additional functionality, such as streaming, security, and monitoring</p><p><strong>Why Use Nginx?</strong></p><p>Nginx is widely used for several compelling reasons, thanks to its architecture and feature set that make it highly efficient, flexible, and reliable.</p><p>1. Scalability</p><p>Its event-driven architecture allows Nginx to scale easily from a few hundred to thousands of concurrent connections on a single server.</p><p>2. Performance</p><p>Optimized for performance, it reduces latency and improves response times.</p><p>3. Reliability</p><p>Nginx is known for its stability and can handle sudden traffic spikes gracefully.</p><p>4. Versatility</p><p>It can serve as a web server, reverse proxy, load balancer, and more, making it a versatile tool in a system administrator’s toolkit.</p><p>5. Security</p><p>With support for SSL/TLS, rate limiting, access control, and more, Nginx helps secure web applications.</p><p>6. Community and Ecosystem</p><p>A large and active community provides extensive documentation, tutorials, and third-party modules.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bad86ef83ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Linux I/O and Redirection Commands]]></title>
            <link>https://medium.com/@leshaan99/the-linux-command-line-understanding-linux-input-output-commands-and-direction-01a195442c04?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/01a195442c04</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Thu, 20 Jun 2024 12:32:34 GMT</pubDate>
            <atom:updated>2025-07-10T09:30:34.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*C0zjH4sMsCvrxcZJ8aIZhA.png" /></figure><p>Linux commands are a fundamental aspect of interacting with the operating system, enabling users to perform a variety of tasks through the command-line interface (CLI). Understanding how to manage input and output in Linux, including command structure and redirection, is essential for efficient system operation and automation.</p><p><strong>Command Structure</strong></p><p>A typical Linux command consists of three main components.</p><ol><li>Command : The name of the program or utility to be executed.</li></ol><p>2. Options/Flags : Modifiers that alter the behavior of the command, usually prefixed with a hyphen (-) or double hyphen (- -).</p><p>· <strong>Single-Character Options</strong></p><p>Single-character options are short, usually a single letter, and are preceded by a single hyphen (-). They can often be combined together after a single hyphen if they don’t require arguments.</p><pre>ls -a</pre><p>· <strong>Full-Word Options</strong></p><p>Full-word options are more descriptive and are preceded by two hyphens (- -). They are usually used for readability and clarity.</p><pre>ls --all</pre><p>3. Arguments : The targets or inputs for the command, such as filenames, directories, or other data.</p><p>Here is the example code for linux command structure.</p><pre>ls -l /home/user</pre><ul><li>ls : Command to list directory contents.</li><li>-l : Option to use a long listing format.</li><li>/home/user : Argument specifying the directory to list.</li></ul><p><strong>Input and Output Streams</strong></p><p>Linux commands typically interact with three types of data streams.</p><ol><li>Standard Input (stdin)</li><li>Standard Output (stdout)</li><li>Standard Error (stderr)</li></ol><p><strong>1.Standard Input</strong></p><p>Standard Input is the default data stream from which commands and programs read their input.</p><p>· This is the default source of input for commands, typically coming from the keyboard.</p><p>· In the shell, stdin is usually represented by file descriptor 0.</p><p><strong>Input Redirection (&lt;)</strong></p><p>Redirects a file to stdin.</p><pre>command &lt; file.txt</pre><p><strong>2.Standard Output</strong></p><p>When a command or program produces output, it sends this output to stdout by default.</p><p>· This is the default destination for output data from commands, typically displayed on the terminal.</p><p>· In the shell, stdout is represented by file descriptor 1.</p><p><strong>Output Redirection (&gt; and &gt;&gt;)</strong></p><p>“ &gt; ” Redirects the stdout to a file, overwriting the file if it exists.</p><pre>command &gt; file.txt</pre><p>“ &gt;&gt; ” Redirects the stdout to a file, appending to the file if it exists.</p><pre>command &gt;&gt; file.txt</pre><p><strong>3.Standard Error</strong></p><p>The primary purpose of stderr is to output error messages and diagnostics.It allows errors to be separated from regular output, making it easier to debug and handle errors without mixing them with standard output.</p><p>· This is the default destination for error messages from commands, also typically displayed on the terminal.</p><p>· In the shell, stderr is represented by file descriptor 2.</p><p><strong>Error Redirection (2&gt; and 2&gt;&gt;)</strong></p><p>“ 2&gt; ”Redirects the stderr to a file, overwriting the file if it exists.</p><pre>command 2&gt; error.txt</pre><p>“ 2&gt;&gt; ” Redirects the stderr to a file, appending to the file if it exists.</p><pre>command 2&gt;&gt; error.txt</pre><p>Mastering stdin, stdout, stderr, and their redirection enables powerful and flexible command-line operations. These concepts allow users to efficiently manage data streams, capture outputs, handle errors, and automate processes, enhancing productivity and control in a Unix-like environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01a195442c04" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Linux Man Pages — The Built in Help System]]></title>
            <link>https://medium.com/@leshaan99/the-linux-command-line-man-page-f39104913237?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f39104913237</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Wed, 19 Jun 2024 12:32:35 GMT</pubDate>
            <atom:updated>2025-07-10T09:31:53.707Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Linux Man Pages — The Built in Help System</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*C0zjH4sMsCvrxcZJ8aIZhA.png" /></figure><p><strong>What is Man Page?</strong></p><p>The man command in Linux stands for &quot;manual,&quot; and it is a powerful tool used to display the user manual of any command that can be run in the terminal. This manual provides comprehensive documentation about commands, system calls, library functions, and file formats available on Unix-like operating systems. It serves as an essential resource for both novice and experienced users to understand the usage, options, and functionalities of various commands and tools.</p><p><strong>How to Use</strong></p><p>· To view the manual for a specific command</p><pre>man command_name</pre><p>For example, if you want to see the manual for the ls command, you would type</p><pre>man ls</pre><p>· To search for a command by keyword</p><pre>man -k keyword</pre><p>For example searching for directory-related commands</p><pre>man -k directory</pre><p>· To navigate within a man page, use the arrow keys, and press q to exit.</p><p><strong>Typical Sections of a </strong><strong>man Page</strong></p><p>1. Name — A brief description of the command.</p><p>2. Synopsis — The general usage of the command, including its options and arguments.</p><p>3. Description — A more detailed description of what the command does.</p><p>4. Options — A list and description of the command-line options that can be used with the command.</p><p>5. Examples — Practical examples of how to use the command.</p><p>6. See Also — References to related commands or documentation.</p><p>Here’s an example to illustrate a typical man page for the which command, which lists directory contents</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-n2V7PC9qhEuCW1S9l-8g.png" /><figcaption>example for man page</figcaption></figure><p>The man command is an invaluable resource for learning and troubleshooting in a Unix-like environment, providing quick access to detailed documentation for a vast array of commands and tools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f39104913237" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with the Linux Terminal]]></title>
            <link>https://medium.com/@leshaan99/the-linux-command-line-how-to-get-start-with-linux-terminal-f8f3750ada23?source=rss-64f91930c1c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8f3750ada23</guid>
            <dc:creator><![CDATA[Leshan Sanjeewa]]></dc:creator>
            <pubDate>Tue, 18 Jun 2024 02:32:31 GMT</pubDate>
            <atom:updated>2025-07-10T09:34:34.342Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*C0zjH4sMsCvrxcZJ8aIZhA.png" /></figure><p><strong>What is Linux?</strong></p><p>Linux is an open-source operating system that sits at the heart of countless devices and applications. Unlike proprietary operating systems like Windows or macOS, Linux is free to use, modify, and distribute. Its open-source nature has fostered a vast, collaborative community of developers who continuously improve and expand its capabilities.</p><p><strong>Linux Terminal</strong></p><p>The Linux terminal, also known as the command line or shell, is a powerful tool that allows you to interact with your system in a more direct and flexible way than a graphical user interface (GUI) can provide.</p><p><strong>· Opening the Terminal</strong></p><p>In ubuntu press</p><pre>Ctrl + Alt + T</pre><p>or search for “Terminal” in the application menu.</p><p>· <strong>Understanding the Prompt</strong></p><p>When you open the terminal, you’ll see a prompt that looks something like this</p><pre>username@hostname:~$</pre><p>username: Your current user name.</p><p>hostname: The name of your computer.</p><p>·<strong> Basic Commands</strong></p><p><strong>echo</strong> — to print a simple string to the terminal</p><pre>echo &quot;Hello, World!&quot;</pre><p><strong>pwd</strong> — displays the full path to the current directory</p><pre>pwd</pre><p><strong>ls — </strong>lists files and directories in the current directory</p><pre>ls</pre><p><strong>cd</strong> — to navigate to a specific directory</p><pre>cd /home/user/Documents</pre><p><strong>history</strong> — to see the list of previously executed commands</p><pre>history</pre><p><strong>clear</strong> — to clear all the previous commands and outputs from the terminal screen</p><pre>clear</pre><p><strong>mkdir</strong> — make Directory(creates a new folder)</p><pre>mkdir newfolder</pre><p><strong>touch</strong> — creates a new empty file</p><pre>touch new_file.txt</pre><p><strong>cp </strong>— copies files</p><pre>cp source_file destination_location</pre><p><strong>cp</strong> — copies directories</p><pre>cp -r source_file destination_location</pre><p><strong>mv</strong> — moves files or directories</p><pre>mv source_file destination_location</pre><p><strong>mv</strong> — renames files or directories</p><pre>mv old_name new_name</pre><p><strong>rm </strong>— deletes files</p><pre>rm source_file</pre><p><strong>rm</strong> — deletes directories</p><pre>rm -rh source_file</pre><p><strong>Essential Terminal Shortcuts</strong></p><p>· Ctrl + D : Exit the terminal (or log out if you&#39;re in a shell)</p><p>· Ctrl + L : Clear the terminal screen</p><p>· Up Arrow : Display the previous command in the history</p><p>· Down Arrow : Display the next command in the history</p><p>· Tab : Auto-complete file and directory names</p><p>· !! : Repeat the last command</p><p>· !n : Repeat the nth command from history</p><p>These basics provide a strong foundation for using the Linux terminal effectively. As you become more comfortable, you can explore more advanced commands and scripting to further enhance your workflow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8f3750ada23" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>