This blog shows you how to deploy existing Django applications inside EC2. The steps are almost similar for other applications like React or angular. You just need to know how to install any application.
Ways to get Application code inside the EC2:
- Upload code in Github. Then clone the repo inside the EC2.
- Upload code in Amazon S3. Then use the AWS copy command to get data into EC2.
Both ways are good as per requirement and usage.
Note: While using the S3 approach you need to create an IAM role for EC2 so that it can access S3. To check the attached policy use the below command in EC2.
Note: While using the S3 approach you need to create an IAM role for EC2 so that it can access S3. To check the attached policy use the below command in EC2.
Deploying Application:
Step 1: Create an EC2 Machine with default configs.
Step 2: Get the Application code in the EC2/ VM.
Step 3: Install Python, pip, and other necessary package.
Step 4: Add public IP inside an Allowed host array of settings.py file.
Step 5: Run the manage.py file.
Step 6: (Optional) The Python command will terminate when you close the terminal. Linux command tmux helps with this.
Step 7: Create an inbound rule for EC2 to access ports on the internet. In our case, we allow 8000.
For More info refer video below.
Conclusion: It's a simple task. I hope you like it. Try to debug errors on your own. Also, comment down if you would like to learn other topics.