<?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 KaVeer Panthi on Medium]]></title>
        <description><![CDATA[Stories by KaVeer Panthi on Medium]]></description>
        <link>https://medium.com/@kvr24611?source=rss-674a8b701981------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*qKPaZ0RGQAGvDLDQ</url>
            <title>Stories by KaVeer Panthi on Medium</title>
            <link>https://medium.com/@kvr24611?source=rss-674a8b701981------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 18:29:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kvr24611/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[Deploying a Python Web App on EC2 with Nginx: A Step-by-Step Guide from VPC to Production]]></title>
            <link>https://medium.com/@kvr24611/deploying-a-python-web-app-on-ec2-with-nginx-a-step-by-step-guide-from-vpc-to-production-f4c1a54e6c16?source=rss-674a8b701981------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4c1a54e6c16</guid>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[KaVeer Panthi]]></dc:creator>
            <pubDate>Sat, 21 Jun 2025 04:59:41 GMT</pubDate>
            <atom:updated>2025-06-21T04:59:41.543Z</atom:updated>
            <content:encoded><![CDATA[<h3>From VPC Creation to Production Setup</h3><h3>📝 Introduction</h3><p>This guide walks you through deploying a Python web app manually on AWS EC2 — including VPC setup, installing necessary packages, creating a systemd service, and configuring Nginx as a reverse proxy.</p><p>By the end, your app will be live and production-ready.</p><h3>🧱 Step 1: Create a Virtual Private Cloud (VPC)</h3><h3>1.1 Create a New VPC</h3><ul><li>Go to <strong>VPC Dashboard → Your VPCs → Create VPC</strong></li><li>Select <strong>VPC and more</strong>, and set:</li><li><strong>Name</strong>: django-app</li><li><strong>IPv4 CIDR block</strong>: 10.0.0.0/16</li><li><strong>Tenancy</strong>: default</li><li>Number of Availability Zones (AZs): 2</li><li>Number of public subnets: 2</li><li>Number of private subnets: 2</li><li>NAT gateways ($): In 1 AZ</li><li>VPC endpoints: None</li></ul><p>Your VPC resource map will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7_S9c6NHPgX-Ro03NNAB3g.png" /><figcaption>VPC Resource Map</figcaption></figure><h3>🖥️ Step 2: Launch an EC2 Instance</h3><h3>2.1 Launch EC2</h3><ul><li>Go to <strong>EC2 Dashboard → Instances → Launch Instances</strong></li><li>Fill out the data:</li><li><strong>Name:</strong> django-full-stack-app</li><li><strong>AMI</strong>: Ubuntu Server 24.04 LTS</li><li><strong>Instance type</strong>: t2.micro</li><li><strong>Key pair</strong>: Create or choose existing</li><li><strong>Edit the Network settings</strong>:</li><li>VPC: django-app-vpc</li><li><strong>Subnet</strong>: public-subnet</li><li><strong>Public IP</strong>: Enable auto-assign</li><li><strong>Security group</strong>: Create one with:</li><li><strong>SSH</strong>: TCP 22</li><li><strong>HTTP</strong>: TCP 80</li><li><strong>Custom TCP</strong>: TCP 8000 (for django application)</li></ul><h3>2.2 Connect to Instance</h3><pre>sudo chmod 400 &quot;your-key.pem&quot;<br>ssh -i &quot;your-key.pem&quot; ubuntu@&lt;your-ec2-public-ip&gt;</pre><h3>🐍 Step 3: Install Python &amp; Nginx</h3><h3>3.1 Switch to Super User (root)</h3><pre>sudo su</pre><h3>3.1 Update Packages</h3><pre>apt update &amp;&amp; sudo apt upgrade -y</pre><h3>3.2 Install Python &amp; Pip</h3><pre>apt install python3 python3-pip python3-venv</pre><h3>3.3 Install Nginx</h3><pre>apt install nginx -y<br>systemctl start nginx<br>systemctl enable nginx</pre><h3>🌱 Step 4: Clone a Sample Django Application</h3><h3>4.1 Clone a public repo</h3><pre>cd /opt<br>mkdir app<br>cd app/<br>git clone https://github.com/technologychannel/DjangoCountryCapitalProject.git</pre><h3>4.2 Create and activate a virtual environment</h3><pre>python3 -m venv venv<br>source venv/bin/activate</pre><h3>4.3 Install project dependencies</h3><pre>cd DjangoCountryCapitalProject/<br>pip install -r requirements.txt</pre><h3>4.4 Run Locally (Optional Test)</h3><pre>python manage.py runserver 0.0.0.0:8000</pre><h3>🛠️ Step 5: Create a systemd Service</h3><h3>5.1 Create service file</h3><pre>nano /etc/systemd/system/django-app.service</pre><p>Paste:</p><pre>[Unit]<br>Description=Django Application Service<br>After=network.target</pre><pre>[Service]<br>User=ubuntu<br>Group=ubuntu<br>WorkingDirectory=/opt/app/DjangoCountryCapitalProject<br>Restart=on-failure<br>ExecStart=/opt/app/venv/bin/python /opt/app/DjangoCountryCapitalProject/manage.py runserver 0.0.0.0:8000</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><h3>5.2 Enable and Start Service</h3><pre>systemctl daemon-reload<br>systemctl start django-app<br>systemctl enable django-app</pre><p>Check status:</p><pre>systemctl status django-app</pre><h3>🌐 Step 6: Configure Nginx as a Reverse Proxy</h3><h3>6.1 Modify the Nginx Config file</h3><pre>&gt; /etc/nginx/nginx.conf<br>nano /etc/nginx/nginx.conf</pre><p>Paste:</p><pre># For more information on configuration, see:<br>#   * http://nginx.org/en/docs/<br>#   * http://nginx.org/ru/docs/<br><br>user root;<br>worker_processes auto;<br>error_log /var/log/nginx/error.log notice;<br>pid /run/nginx.pid;<br><br># Load dynamic modules.<br>include /usr/share/nginx/modules/*.conf;<br><br>events {<br>    worker_connections 1024;<br>}<br><br>http {<br>    log_format  main  &#39;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#39;<br>                      &#39;$status $body_bytes_sent &quot;$http_referer&quot; &#39;<br>                      &#39;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#39;;<br><br>    access_log  /var/log/nginx/access.log  main;<br><br>    sendfile            on;<br>    tcp_nopush          on;<br>    keepalive_timeout   65;<br>    types_hash_max_size 4096;<br><br>    include             /etc/nginx/mime.types;<br>    default_type        application/octet-stream;<br><br>    # Load reverse proxy config for Django<br>    include /etc/nginx/conf.d/*.conf;<br>}</pre><h3>6.2 Create Site Config</h3><pre>nano /etc/nginx/conf.d/django-app.conf</pre><p>Paste:</p><pre>server {<br>    listen 80;<br>    server_name _;<br><br>    location / {<br>        proxy_pass http://127.0.0.1:8000;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto $scheme;<br>    }<br>}</pre><h3>6.3 Enable and Restart Nginx</h3><pre>nginx -t<br>systemctl restart nginx</pre><h3>✅ Step 8: Access the application with the EC2 public IP</h3><pre>Enter your EC2 Public IP in the browser.</pre><h3>📌 Final Checklist</h3><ul><li>✅ Custom VPC created and configured</li><li>✅ EC2 instance launched and SSH connected</li><li>✅ Python app running</li><li>✅ systemd service created</li><li>✅ Nginx reverse proxy working</li><li>✅ Launch the application from the browser</li></ul><h3>🙌 Conclusion</h3><p>Congratulations! 🎉</p><p>You’ve deployed a Python web app from scratch on AWS EC2 using your own VPC and Nginx setup.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4c1a54e6c16" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>