<?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>Forem: Deniel Dave Natividad</title>
    <description>The latest articles on Forem by Deniel Dave Natividad (@deniel_davenatividad_f4f).</description>
    <link>https://forem.com/deniel_davenatividad_f4f</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%2F2214395%2Fd1dbac22-728c-4166-9ba4-1844f2a424c1.png</url>
      <title>Forem: Deniel Dave Natividad</title>
      <link>https://forem.com/deniel_davenatividad_f4f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/deniel_davenatividad_f4f"/>
    <language>en</language>
    <item>
      <title>Unlock the Power of the Cloud: Deploy Your Django App on AWS EC2</title>
      <dc:creator>Deniel Dave Natividad</dc:creator>
      <pubDate>Mon, 04 Nov 2024 15:52:06 +0000</pubDate>
      <link>https://forem.com/deniel_davenatividad_f4f/unlock-the-power-of-the-cloud-deploy-your-django-app-on-aws-ec2-7d7</link>
      <guid>https://forem.com/deniel_davenatividad_f4f/unlock-the-power-of-the-cloud-deploy-your-django-app-on-aws-ec2-7d7</guid>
      <description>&lt;p&gt;You’re happily coding away on your Django Web App, and now you’re ready to deploy it in a production cloud environment. But the transition from local development to a robust, secure, and scalable production setup can be challenging. You want your app to be easily accessible to clients, have robust security for malicious actors all while hosted on a cloud provider with a reliable architecture that will give you peace of mind. While Django is good for handling all your Web App needs, moving from local to a production environment will certainly present new challenges.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS as a Cloud Service Provider
&lt;/h2&gt;

&lt;p&gt;AWS is one of those cloud service providers. They certainly achieve all our checklists for moving on a production environment with their various services and global network of data centers. It offers the scalability to handle varying user demands, the security tools to protect user data, and the reliability needed for high availability. For developers looking to move from local to cloud, AWS provides the infrastructure and flexibility to make the transition smooth and sustainable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Harboring the power of AWS EC2
&lt;/h2&gt;

&lt;p&gt;AWS EC2 or Elastic Compute Cloud is a really practical and widely used service for hosting web apps, offering on-demand, scalable computing capacity. With EC2, you can minimize upfront hardware costs and focus on developing and deploying your application faster. Its flexibility in instance types and configurations allows you to scale resources as needed, making it an ideal choice for supporting a growing user base in a reliable and cost-effective manner.&lt;/p&gt;

&lt;p&gt;AWS Elastic Compute Cloud offers a wide range of features that will help you deploy a future proof application.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Elasticity&lt;/strong&gt; is one of its main features, that allows you to configure an &lt;strong&gt;Auto Scaling Groups&lt;/strong&gt; (ASGs) to automatically adjust capacity in response to changing traffic loads, ensuring that your app performs reliably even during high traffic situations. &lt;/li&gt;
&lt;li&gt;EC2 also prioritizes &lt;strong&gt;security with Security Groups&lt;/strong&gt; and &lt;strong&gt;Virtual Private Clouds&lt;/strong&gt; (VPCs), providing network-level protection and controlled access to your instances, which helps safeguard user data and sensitive app components. &lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;cost management&lt;/strong&gt;, EC2’s flexible pricing model—spanning on-demand, reserved, and spot instances—lets you optimize costs based on your application’s needs, fitting various budget constraints. &lt;/li&gt;
&lt;li&gt;Finally, &lt;strong&gt;EC2 integrates seamlessly with the broader AWS ecosystem&lt;/strong&gt;, offering easy access to services like RDS for databases, S3 for storage, and IAM for access control, enabling a cohesive, scalable, and secure setup that covers all the essentials for production-ready Django deployments.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Launching an EC2 Instance
&lt;/h1&gt;

&lt;p&gt;In the AWS Management Console, type &lt;code&gt;EC2&lt;/code&gt; in the search bar or locate it under the &lt;strong&gt;Services&lt;/strong&gt; menu. Click on &lt;strong&gt;EC2&lt;/strong&gt; to open the EC2 Dashboard.&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%2Fclwcacdxau1rtjzlg5we.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%2Fclwcacdxau1rtjzlg5we.png" alt="Image description" width="800" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Launching the Instance
&lt;/h4&gt;

&lt;p&gt;On the EC2 Dashboard, click the &lt;strong&gt;Launch Instance&lt;/strong&gt; button to start the instance creation process.&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%2F1h0hxgu1ghjn6pmp19n9.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%2F1h0hxgu1ghjn6pmp19n9.png" alt="Image description" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Naming and Tagging Your Instance
&lt;/h4&gt;

&lt;p&gt;Create a name for your instance. &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%2Fvxufom1199ul8fds0vnr.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%2Fvxufom1199ul8fds0vnr.png" alt="Image description" width="753" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Selecting an AMI (Amazon Machine Image)
&lt;/h4&gt;

&lt;p&gt;AMIs are preconfigured templates for your instances, containing the operating system and software you want. Choose ‘Amazon Linux’.&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%2F0jmpslmk60j3u3x99p22.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%2F0jmpslmk60j3u3x99p22.png" alt="Image description" width="720" height="569"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Choosing an Instance Type
&lt;/h4&gt;

&lt;p&gt;An instance type in Amazon EC2 defines the virtual hardware for your server, such as CPU, memory, storage, and network capacity. Different types are suited for different workloads. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Choose t2.micro&lt;/strong&gt; for this one as it's affordable, Free Tier eligible, and offers on-demand usage where you only pay for what resources you use.&lt;/li&gt;
&lt;/ul&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%2Fht2rlxikn74l25ns7g3t.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%2Fht2rlxikn74l25ns7g3t.png" alt="Image description" width="712" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Configuring a Key Pair
&lt;/h4&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%2F2kdd5wz1y8e9uos7moem.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%2F2kdd5wz1y8e9uos7moem.png" alt="Image description" width="554" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For this time, lets not create a keypair. We will connect to the instance using the AWS console.&lt;/p&gt;

&lt;h4&gt;
  
  
  6. Configuring Networking
&lt;/h4&gt;

&lt;p&gt;These are some minute networking details for your instance.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Network:&lt;/strong&gt; The network defines the Virtual Private Cloud (VPC) where your instance will reside.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subnet:&lt;/strong&gt; A subnet is a segment of a VPC's IP address range.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto-assign Public IP:&lt;/strong&gt; This setting automatically assigns a public IP address to your instance.&lt;/li&gt;
&lt;/ul&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%2Fh1h267yto6p37gnsfj83.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%2Fh1h267yto6p37gnsfj83.png" alt="Image description" width="692" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  7. Configuring Security Groups
&lt;/h4&gt;

&lt;p&gt;Security groups act as virtual firewalls for your Amazon EC2 instances. They control inbound and outbound traffic based on defined rules. Choose &lt;strong&gt;create security group&lt;/strong&gt; and check &lt;strong&gt;allow SSH traffic&lt;/strong&gt;. This allows us to connect to our instance later.&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%2F9p98q57viwxv276r8umx.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%2F9p98q57viwxv276r8umx.png" alt="Image description" width="683" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  8. Configuring Storage
&lt;/h4&gt;

&lt;p&gt;This will specify the storage options of your instance. Leave the option as it is. Here are the details you need to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1x:&lt;/strong&gt; This indicates that there is one volume attached as the root volume to the EC2 instance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;8 GiB:&lt;/strong&gt; This specifies the size of the root volume, which is 8 GiB (Gibibytes). &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;gp3:&lt;/strong&gt; This indicates the type of storage volume. gp3 is a type of General Purpose SSD (Solid State Drive) that offers a balance of price and performance.&lt;/li&gt;
&lt;/ul&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%2F8hobvebcplc4vpsepkem.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%2F8hobvebcplc4vpsepkem.png" alt="Image description" width="684" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  9. Reviewing and Launching
&lt;/h4&gt;

&lt;p&gt;Review your configured instance. If everything looks correct, click &lt;strong&gt;launch instance&lt;/strong&gt;.&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%2Fwra17gasq39gn64xwlus.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%2Fwra17gasq39gn64xwlus.png" alt="Image description" width="332" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  10. Accessing the Instance
&lt;/h4&gt;

&lt;p&gt;You will proceed to this page, just click the instance ID.  &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%2F4bizwlgdtzt347n9bcpg.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%2F4bizwlgdtzt347n9bcpg.png" alt="Image description" width="800" height="129"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The instance will take time to initialize. It will usually take 2-3 minutes. &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%2Fs664lzjhfm2a4zk804q5.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%2Fs664lzjhfm2a4zk804q5.png" alt="Image description" width="800" height="123"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Django on a Git Repository
&lt;/h2&gt;

&lt;p&gt;Now that you have your EC2 instance running, you can now deploy your Django application. We will clone it from a remote repository. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/euxia/django-on-ec2" rel="noopener noreferrer"&gt;Link to remote repo&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;This remote repo is not made by me, all credits to the author. He also had a guide on how to deploy Django on EC2 in his README.md file. you can check it out. His guide is on Ubuntu, but we will be using Amazon Linux.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deploying Django on EC2
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Connecting to the instance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Click the instance ID to open the instance details. Then click &lt;strong&gt;Connect&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&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%2F08qmair82iyst0xv6g7x.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%2F08qmair82iyst0xv6g7x.png" alt="Image description" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lets choose EC2 Instance Connect as the connection method and click &lt;strong&gt;Connect&lt;/strong&gt;. This is due to the fact that we did not create a keypair and it is much easier to connect using this method.&lt;/li&gt;
&lt;/ul&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%2Fa0y7ipnoke44xiydrxoz.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%2Fa0y7ipnoke44xiydrxoz.png" alt="Image description" width="623" height="583"&gt;&lt;/a&gt;&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%2Fpln61tgpmzblbrr9gmar.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%2Fpln61tgpmzblbrr9gmar.png" alt="Image description" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring Django dependencies on the instance
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Update the package list system
&lt;/li&gt;
&lt;/ul&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;yum update &lt;span class="nt"&gt;-y&lt;/span&gt;
&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%2Fn30jqd6adyd5308phclp.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%2Fn30jqd6adyd5308phclp.png" alt="Image description" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lets install git
&lt;/li&gt;
&lt;/ul&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;yum &lt;span class="nb"&gt;install &lt;/span&gt;git 
&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%2Fgik7z88nn05ncr8b902c.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%2Fgik7z88nn05ncr8b902c.png" alt="Image description" width="800" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clone the repository
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/euxia/django-on-ec2
&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%2Fnr5y4i5x7knoz9k5uoqt.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%2Fnr5y4i5x7knoz9k5uoqt.png" alt="Image description" width="712" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Python3 and Django
&lt;/li&gt;
&lt;/ul&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;yum &lt;span class="nb"&gt;install &lt;/span&gt;python3-pip &lt;span class="nt"&gt;-y&lt;/span&gt;
&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%2Fqy8ltpnm49e73btbpknq.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%2Fqy8ltpnm49e73btbpknq.png" alt="Image description" width="685" height="313"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;django
&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%2F3ext4uxszb8ia3nhx0an.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%2F3ext4uxszb8ia3nhx0an.png" alt="Image description" width="719" height="271"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Go to the repository and run the Django server
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to the repository
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;django-on-ec2
&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%2Ft377idco1n3fsi9ooqi2.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%2Ft377idco1n3fsi9ooqi2.png" alt="Image description" width="431" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lets create a migration. This prepares the changes in your models to be applied to the database
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 manage.py makemigrations
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 manage.py migrate
&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%2Ffvk7eukw2cxq0953s2wj.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%2Ffvk7eukw2cxq0953s2wj.png" alt="Image description" width="688" height="41"&gt;&lt;/a&gt;&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%2Fwl1ols2c53dfr4hon2il.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%2Fwl1ols2c53dfr4hon2il.png" alt="Image description" width="628" height="136"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lets create a superuser. This is the admin user for the Django application.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 manage.py createsuperuser
&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%2Fpdj2aax0sfdfl54csaeb.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%2Fpdj2aax0sfdfl54csaeb.png" alt="Image description" width="703" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Tip: You can skip the email part if you want.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the Django server
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 manage.py runserver
&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%2F6cgrj6kparenrc36vn60.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%2F6cgrj6kparenrc36vn60.png" alt="Image description" width="643" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the server is running on a local IP address. But we can't access it from the internet as it is running on a production server. We will need to run it on a public IP address of the EC2 instance itself.&lt;/p&gt;




&lt;h3&gt;
  
  
  Running Django on a public IP address
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stop the server by pressing &lt;code&gt;Ctrl + C&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the server on a public IP address&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 manage.py runserver 0.0.0.0:8000
&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%2Fiu636ot3crqxdpz8z4n5.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%2Fiu636ot3crqxdpz8z4n5.png" alt="Image description" width="776" height="89"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will run the server on a public IP address accessible from everywhere, on all network interfaces. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find the public IP address of the instance then add &lt;code&gt;:8000&lt;/code&gt; to the end of the IP address.&lt;/li&gt;
&lt;/ul&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%2Fs7d3g95yf63ftsk78gop.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%2Fs7d3g95yf63ftsk78gop.png" alt="Image description" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search the public IP address on your browser and you will see the Django application still not running.&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%2Fynnpq7z9k5m1qkvcj9wb.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%2Fynnpq7z9k5m1qkvcj9wb.png" alt="Image description" width="700" height="401"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Allowing traffic on port 8000
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to the EC2 instance, scroll down, and find the security group. Click on the security group ID.&lt;/li&gt;
&lt;/ul&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%2Fdncfn06f094azpypmnqe.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%2Fdncfn06f094azpypmnqe.png" alt="Image description" width="800" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the &lt;strong&gt;Inbound rules&lt;/strong&gt; tab and click &lt;strong&gt;Edit inbound rules&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&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%2F97gkyfqwo1e9j3w9lqah.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%2F97gkyfqwo1e9j3w9lqah.png" alt="Image description" width="800" height="263"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Add rule&lt;/strong&gt; and add the following details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type:&lt;/strong&gt; Custom TCP Rule&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protocol:&lt;/strong&gt; TCP&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Port Range:&lt;/strong&gt; 8000&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source:&lt;/strong&gt; Anywhere&lt;/li&gt;
&lt;/ul&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%2Fpoylf23sf3ogxi59bwhz.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%2Fpoylf23sf3ogxi59bwhz.png" alt="Image description" width="800" height="299"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Click &lt;strong&gt;Save rules&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Go back to the browser and refresh the page. You will see the Django application running.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2F5jgwyowvgxaz6dg72d6b.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%2F5jgwyowvgxaz6dg72d6b.png" alt="Image description" width="800" height="356"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Deploying a Django web app on AWS EC2 illustrates the power and versatility of cloud infrastructure—not just for Django, but for a wide variety of web frameworks and languages. The steps involved, such as configuring inbound rules to allow specific port permissions and setting up security groups, can be applied equally to applications built with Flask, Node.js, and even frontend frameworks like Next.js. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>aws</category>
      <category>beginners</category>
      <category>cloud</category>
    </item>
  </channel>
</rss>
