Deploy Django Application on AWS EC2 with PostgreSQL and S3 Storage
Вставка
- Опубліковано 23 лип 2024
- In this video, learn how to deploy a Django application on an AWS EC2 instance with PostgreSQL and S3 storage while setting up a custom domain and SSL certificate.
GitHub Actions CI/CD Pipeline: • Deploy project on Goog...
Become A Backend Developer in 3 hours: • Become a Backend Devel...
We'll start by launching an EC2 instance, configuring security groups, and installing necessary packages.
Then, we'll create a PostgreSQL database, set up S3 storage, and configure our Django application to use them.
Finally, we'll set up a custom domain and configure SSL encryption using Let's Encrypt, so your application is secure and accessible to your users.
This tutorial is perfect for anyone looking to deploy a scalable Django application on AWS and ensure it's secure and reliable. So, let's get started!
_ _ _ _ _ _ _ _ _ _ _ _ __ __ _ _ _ _
About Channel:
CodeWithMuh is here to help people learn about DevOps, software development, AWS, Google Cloud, and much more. I want to make it easy and quick for new developers to understand things. I also provide articles to help you learn even better with every video.
If you like what I'm doing, you can support me by subscribing to my channel and sharing it on your social media. Let's learn and have fun together!
_ _ _ _ _ _ _ _ _ _ _ _ __ __ _ _ _ _
Contact:
Email: codewithmuh@gmail.com
LinkedIn: / muhammad-rashid-daha
_ _ _ _ _ _ _ _ _ _ _ _ __ __ _ _ _ _
Resources:
Article: / deploy-django-applicat...
GitHub Repository: github.com/codewithmuh/backen...
Subscribe to MY Newsletter: / 7142487325682446336
_ _ _ _ _ _ _ _ _ _ _ _ __ __ _ _ _ _
If you would like to consult with me or hire me, please let me know.
Hire me on Upwork: www.upwork.com/freelancers/~0...
Place an order on Fiverr: www.fiverr.com/s/rBpEdD
_ _ _ _ _ _ _ _ _ _ _ _ __ __ _ _ _ _
Social Links:
Github: github.com/codewithmuh
LinkedIn: / muhammad-rashid-daha
Upwork: www.upwork.com/freelancers/~0...
X: / rashiddaha80
Instagram: / rashiddaha1
Medium: / codewithmuh
Website: codewithmuh.com
_ _ _ _ _ _ _ _ _ _ _ _ __ __ _ _ _ _
Table of Contents:
0:00:00 Introduction
0:01:48 Part 01: AWS RDS PostgreSQL
0:13:49 Part 01: AWS S3 Bucket
0:23:44 Part 01: Deployment on AWS EC2
0:48:27 Part 02: Domain Setup
0:53:34 Part 02: SSL Certificate
#aws
Connect with me on LinkedIn: www.linkedin.com/in/muhammad-rashid-daha
Video and tutorials to the point! It works for me. Thank you very much
Glad to Hear, You liked it.
Thank you very much for this video, It has really helped me 🙏🙏🙏
Happy to hear
amazing work! You saved my life for my project . Thank you very much !!!
happy to hear
You're awesome man! I've tried any tutorials but always the static files don't work, but you came with a simple solution, thanks man!! Definitely one more subscriber
Glad to hear 🚀
@@CodeWithMuh HEy buddy, my AWS Data Transfer is getting almost in the limit of the free tier since yesterday that I've completed the deploy. So, I think I need to use CloudFront + S3 and configure this in the nginx .conf, do you have any video about this? I think the only change aboute this video is the CloudFront
Amazing tutorial. Even ChatGpt couldn't do what you just did there brother. Thank you. I am subscribed and a big fan
Thanks for your Love 😘
Something missing. Some configuration is not explained. It's not working for me. Yes, ChatGPT helped me more.
Bro, thanks for your work! You're the best)
Glad to hear. Don't forget to connect over LinkedIn. 😉
Best tutorial on UA-cam, you have no idea how helpful you were. Saved my life on my school project. Thank you!
Happy to hear. 🌞
Cool, what do you study and where?
Awesome content bro……love from India. Keep it up bro…..we need more videos like this from you…thanks alot
Glad to hear. I will be making
helpfull!!!!! such a nice vdo ! seeking more
More to come!
thanks for your explanation its awsome
Glad to hear.
Very informative video
i was also working on this type of project. It helped me, thank you
Welcome
Absolutely wonderful tutorial, everything works perfectly. Just one small thing -- wish you could have attached the SSL medium article to the description as well.
Here you go: codewithmuh.medium.com/configure-ssl-on-aws-ec2-instance-12e49cebe451
quality content man
GLAD TO HEAR. 💥
Starting watching watching video.
GLAD TO HEAR
good :)
Thanks
thanks
You're welcome!
YOU ARE AMAZING!!!!!!!
Happy to hear
The images uploaded to aws are not being loaded.
@@nataliogomes8303 like where
36:43 static() function has if condition for debug mode settings.DEBUG. So you don't need to create a new if condition again
This is a nice tutorial, Thanks Muh!! +1 Subsciption. Code on Bro
Thanks. 💥
You skipped a very important part towards the end of provisioning a Postgres DB, configuring the inbound security rules. Very important or the database won't be accessible from your app. Informative tutorial overall, thank you
Right.
In this video i did migrations from localhost to RDS. So we can handle from there as well.
But as you said from EC2, you are right.
You can add RDS security group in ec2 security group .
exactly
@@CodeWithMuh yes adding postgres security group to ec2 worked. Thanks
Thank you for your tutorial regarding deployment of django application on AWS it was an amazing learning experience I've waited this for so long, a wonderful tutorial indeed...i closely watch and followed every steps of your tutorial from RDS, S3, IAM running it from my localhost attached to a aws RDS postgreSQL and S3 everything is working fine.. until i started to follow the tutorial for the EC2 from the updating of EC2 environment , to setting up of virtual environment, cloning my git to EC2 set up... started the 'makemigrations' from the terming of EC2..no errors have been displayed however the program hangs and automatically disconnects from EC2 , also done the 'migrate' same no errors but program hangs.. mr. Muh should you have in mind as to what / where I am wrong. please advise. Thank you.
There are chances you have a made mistake somewhere. Reach out to me at LinkedIn with A text message. I will try to help you out
@@CodeWithMuh thank u so much and sorry for my late reply we have different time zone u know.. will get in touch w u later sir Muh….
Thanks for your great video Muhammed. We are looking at deploying our Django (backend) and VueJS (frontend) application. Please let us know if you can take us through this process (online) and how much you will charge for this. Thanks and hope to hear from you.
Please email me at codewithmuh@gmail.com
@@CodeWithMuh Great, I have emailed you just now. Thanks
Just replied you
If I am using S3 for my static files, should I still follow the whitenoise section of this tutorial?
No
I have seen that some people put Ip address or domain in nginx file, this you simplified when you used cloudflare?
No, its not mandatory with cloudflare use
Hi Mr. Muh, Can I just install a PostgreSQL package inside the ssh environment on an AWS EC2 instance without creating or configuring the AWS RDS instance? Thanks for your prompt response.
Yes you can
@@CodeWithMuh thank you for your reply. What will be the 'endpoint' if ever ?
It will be ip
how can i setup environement variables in my ec2 instance as env variables are not in the github repo ?
You have to create .env on ec2 at your project folder
If anyone have "refused to connect" issue, configure gunicorn in the default file.
Hey , i had one small doubt ... The Ipv4 will change whenever we restart the ec2 instance ...right?
Yes, you have to create elastic ip, then attach to ec2. Then it will not get updated
Can you explain to me on why I didn't get the ONLINESHOP Section when I first Logged-in at the Django administration? It only contains the AUTHENTICATION AND AUTHORIZATION Section :< Please help
we had a chat on linkedin.
@@CodeWithMuh Yup ! Thank you very VERY VERY MUCH! I really appreciate it !
Legend!
Glad to hear. My videos are helping others.
Thank you! Please explain to your viewers the reason "why?" you are doing things. Why use white noise? What problem does that solve? Why are any of the settings.py lines added? What do they do? What happens if I do not add the lines?
You are right. I will improve the content by giving some more time. Because to create more in detailed content, it takes time. As i am working as a freelancer, it's become difficult to give time. But now i am managing to give a quality video every week.
I appreciated your feedback, it will help to add some details in my content
I would like to connect with you on LinkedIn.
Muh, I've done all the steps in the EC2 part, but in the end my project is not being display when I run the 'ls' command and I have no idea why, everything else is working correctly
Any help here I would appreciate very much, and tks for this video
There will be a mistake somewhere in your set-up. Send me a message on email
Muh, on minute 10:15 you establish an inbound rule, I try to the same thing but I'm receiving this error:
"You cannot specify an IPv4 CIDR for an existing referenced group ID rule."
How can I fix that??
Very good video, tks!
Can you share screenshot via drive url. Show me how you filled.
There will be mistake. Show me your screenshot, so i can review
Or post here. fb://group/890525732087988?ref=share&mibextid=NSMWBT
@@CodeWithMuh take a look in that word file in my drive
drive.google.com/drive/folders/1kqmLUQZ_sLf51jIqHeLuHgEHV9C0wdNj?usp=sharing
Tks!
@@CodeWithMuh I don't think it's a mistake, I follow your steps, looks like to be a problem in security AWS Service Muh, if you can please, check the file that I've shared with you on my drive
can you explain the purpose of S3 in this setup? is it just for backup and redundancy?
S3 is used to store files. Suppose a blog model has a cover image, when we create a new blog and upload an image, it will be stored over the s3 bucket.
@@CodeWithMuh oh ok. So the data for our database is stored in S3, and not in RDS? I thought RDS is where files were stored because thats where postgres is installed.
Rds is being used for tables. S3 is being used for binary/images/pdf files. Both have different use
Sir I have a problem in nginx 404 page not found my django default admin can you please explain
Nginx is not configured. Please post your nginx screenshot in our Facebook group community for help. Group name is given in video description
My django Restframwork Project is working fine on the public IP address but not on the domain name...
if I try to access using http it says server is down error code 521
!HELP
Make sure your domain is properly pointed to your domain
set the ssl setting to flexible instead of full and it worked..
also used certbot made it more simpler
I am using windows. after pasting the gunicorn code how do I save and exit? Which commands should I use?
Crt + C or CRT+ x.
@@CodeWithMuh thank you
@@sulaimanibrahim7796 does it work for you?
When I try to run the command 'sudo systemctl start gunicorn.socket' I'm receiving an error, so I think it's not saving
@vitorangheben80 yeah it worked for me. When you click ctrl x you'll see a prompt about saving you press y then enter
Hey I have an error when I try it. My IP address works well on the browser but when I connect the domain name to the IP address using Cloudflare I get the welcome to nginx page. When I input the domain name it shows the nginx welcome page. Can you please help?
Share your Nginx file code
I deleted my other nginx configuration and I used yours. My IP address is working but when I type my domain name it shows "Bad request 400" @@CodeWithMuh
bro makemigrations not working for me
RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: role "ubuntu" does not exist
warnings.warn(
anyone know to fix?
Your configurations are worng. Did you added role Ubuntu?
@@CodeWithMuh no friend in which part of the tutorial comes how to do it
Make sure your socket configuration is correct
did it resolve if yes please help me i'm stuck into it
How to fix system has not yet been booted with systemd as init system??? Failed to connect to bus: host us down. Please help me
I didn’t get your issue. Send me message on linkedin
@@CodeWithMuh I did send
how force redirect to https. currently need to enter https manually
you need to install ssl
Did all the steps, but when I try to access the page all I get is “this site can’t be reached” (my ec2 ip) refused to connect….. any help?
You will have issues in gunicorn, nginx, or security groups. Make sure all these things are correctly configured.
@@CodeWithMuh the issue was with the security groups…. Thanks for the great tutorial…
@@Sports-Made Glad to hear
If still not working, configure gunicorn in the default file and try again.
i'm also facing the same issue that you have . i have followed all thing correctly also didnt get any error , could you please share what did you change in the security groups , or please provide you instagram id or any other contact details plsease its urgent
Hello good tutorial, I am running into 502 Bad Gateway Error nginx/1.18.0 (Ubuntu) after configuring the EC2 instance and RDS correctly. Any idea what is wrong?
Check your ngnix file. Also check logs error. Or check Gunicorn errors
Its may be missing of credentials.
check the status of gunicorn
Hello, Bryan how did you solve , running into the same error
Hey, I hate to say it but I used another tutorial to finish
There will be something wrong in nginx. Share your nginx.
Why did not use Route 53 to get a domain?
If you want to use. You can
3:25
this deployment is eligible for a free tier account in aws?
Yes, eligible
Is it still? I'm getting charge for usage of IPv4 address
@@aleda97 same for me :(
Hi, thanks for ur great videos, I got 502 nginx errors after successfully completion of each step in ec2
Your nginx file configuration is well worng. Fix it.
Share it. I can check
Send me message on discord
@@CodeWithMuh ok sure
Hi , Thanks for your content
I went through your video and deployed my djnago application on ec2
after completion, I'm getting like on browser
This site can’t be reached3.93.144.168
refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
Can you please help here, I'm stuck here ,How to fix it
facing the same issue , do you have any solution
😉
Very informative video
Glad to hear you liked it 🙌