<?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: Omoruyi Emmanuel Osakue </title>
    <description>The latest articles on DEV Community by Omoruyi Emmanuel Osakue  (@omoruyi).</description>
    <link>https://dev.to/omoruyi</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F708497%2F49278faf-0893-4cf7-a2e5-64cef84ed13f.png</url>
      <title>DEV Community: Omoruyi Emmanuel Osakue </title>
      <link>https://dev.to/omoruyi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/omoruyi"/>
    <language>en</language>
    <item>
      <title>HNG Internship Week 1</title>
      <dc:creator>Omoruyi Emmanuel Osakue </dc:creator>
      <pubDate>Fri, 07 Feb 2025 22:30:23 +0000</pubDate>
      <link>https://dev.to/omoruyi/hng-internship-week-1-1o6j</link>
      <guid>https://dev.to/omoruyi/hng-internship-week-1-1o6j</guid>
      <description>&lt;p&gt;So... As I said, beginnings are always easy, and HNG dropped a big one on me this week making me think. How about I try to push beyond my capabilities?&lt;br&gt;
So far I have little prerequisite with Python and API technologies, lame I know. But if you're reading this it means I overcame so I implore you to read through this and I'll tell you how&lt;/p&gt;
&lt;h1&gt;
  
  
  Steps to Deploy on EC2:
&lt;/h1&gt;
&lt;h3&gt;
  
  
  Launch an EC2 Instance:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Choose a Linux AMI.&lt;/li&gt;
&lt;li&gt;Select an appropriate instance type (t2.micro).&lt;/li&gt;
&lt;li&gt;Configure security groups to allow inbound HTTP traffic (port 80) and SSH (port 22).&lt;/li&gt;
&lt;li&gt;Connect to your EC2 Instance: Use SSH to connect to your instance.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Install Python and Dependencies:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="nt"&gt;-y&lt;/span&gt;  &lt;span class="c"&gt;# Update system packages&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;python3.12-venv  &lt;span class="c"&gt;# Create a virtual environment&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can clone your GitHub repository and change into it, then activate virtual environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 &lt;span class="nt"&gt;-m&lt;/span&gt; venv venv 
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt &lt;span class="c"&gt;# Install dependencies&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Create a WSGI file (wsgi.py):
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;wsgi.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;  &lt;span class="c1"&gt;# Replace app with your Flask app's name
&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run with Gunicorn (Recommended for Production):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gunicorn &lt;span class="nt"&gt;--bind&lt;/span&gt; :8000 wsgi:app  &lt;span class="c"&gt;# Run Gunicorn on port 8000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You could run this in the background using &lt;code&gt;nohup&lt;/code&gt; or &lt;code&gt;screen&lt;/code&gt; so it continues to run after you disconnect from SSH.&lt;/p&gt;

&lt;p&gt;Configure a Reverse Proxy (Nginx or Apache): &lt;code&gt;sudo apt install nignx -y&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A reverse proxy is highly recommended for production.  It handles static files, load balancing, and more.  Here's a basic Nginx configuration example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;your_ec2_public_ip_or_dns&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;# Replace with your EC2 instance's public IP or DNS&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_pass&lt;/span&gt; &lt;span class="s"&gt;http://127.0.0.1:8000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;# Forward requests to Gunicorn&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Host&lt;/span&gt; &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Real-IP&lt;/span&gt; &lt;span class="nv"&gt;$remote_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Place this configuration in /etc/nginx/conf.d/your_app.conf and restart Nginx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart nginx.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Get your EC2 Public IP or DNS: You can find this in the EC2 console. Use this to access your API: &lt;a href="http://54.204.77.176/api/classify-number?number=371" rel="noopener noreferrer"&gt;http://54.204.77.176/api/classify-number?number=371&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>HNG Internship Begins</title>
      <dc:creator>Omoruyi Emmanuel Osakue </dc:creator>
      <pubDate>Thu, 30 Jan 2025 10:03:17 +0000</pubDate>
      <link>https://dev.to/omoruyi/hng-internship-4c1m</link>
      <guid>https://dev.to/omoruyi/hng-internship-4c1m</guid>
      <description>&lt;p&gt;Beginnings are always easy, for example, this is the beginning of my 8-week internship journey with HNG, and as excited as I am, I am resolved to overcome any challenges I would likely encounter in this program's tasks. That said, let us begin.&lt;/p&gt;

&lt;h2&gt;
  
  
  DevOps Stage O Task
&lt;/h2&gt;

&lt;p&gt;Interns are tasked with setting up and configuring NGINX on a fresh Ubuntu server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;For this task, I will use AWS Cloud because I am familiar with it, but as I've stated, I am challenging myself, so expect this task to be redone in other cloud providers' compute instances.&lt;br&gt;
First I will begin by launching the AWS compute--instance EC2, picking Ubuntu AMI, and allowing ports 22 and 80. Next, I connect to the instance via SSH &lt;br&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%2Fkq4oa6e0nutqhw2qr649.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%2Fkq4oa6e0nutqhw2qr649.png" alt="Connect to instance" width="800" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After getting into the server I would run an update and install NGINX with the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &amp;amp; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nginx &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I'll navigate to the directory where my webpage will be served&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /var/www/html/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once there I create a new file using sudo permission and add my HTML code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vi index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="na"&gt;DOCTYPEhtml&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Welcome to DevOps Stage 0&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Omoruyi Emmanuel Osakue/Omoruyi&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we run a restart for the service&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service nginx restart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s check if everything works as it should. Open our newly created site in a web browser.&lt;br&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%2F9yi7dvoj1dur5nx8fyrw.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%2F9yi7dvoj1dur5nx8fyrw.png" alt="Web page" width="800" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything works as it should. We have just configured the Nginx web server.&lt;/p&gt;

&lt;p&gt;Now while working on this project I initially tried editing my HTML file in the /www/html/ directory without sudo permissions which of course failed after which I learned to use the sudo permissions&lt;/p&gt;

&lt;p&gt;This task demonstrates my ability to work with basic web server configurations and deliver a functional web server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://hng.tech/hire/devops-engineers" rel="noopener noreferrer"&gt;DevOps Engineers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hng.tech/hire/cloud-engineers" rel="noopener noreferrer"&gt;Cloud Engineers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
