Man! You just made our entire life! We were struggling for the past 3 days just to get a Django website up and running! Thanks for being the guardian angel.
For anyone having trouble installing uwsgi or any other package for that matter into ur virtual enviroment, make sure the user ur working with owns the virtual enviroment. Do not use sudo, cause you really dont want any of these packages to be installed globably. Also, uwsgi depends on gcc, python dev and wheels. Hope this helps anyone stuck. (any packaged with pip)
The best django deployment tutorial i found, i plan to use docker and google cloud run for my deployment, but i just want to test the server deployment to learn some details about how everything works together, thanks a lot, works like a charm
Hi Tony. Great tutorial, I really appreciate it! I want to add a little thing, perhaps someone is running into the same problem. When setting the uwsgi.ini file (around 28:00) , I had to comment out the ' home' line for it to work. Logs showed an error when mapping the PYTHONHOME, commenting that line out solved the issue.
Hello, after 2 days of struggling with this installation, I found your video and explanations. First of all, thank you very much. Although I used all the parameters such as user and domain as yours, I encountered some errors. I wanted to write some notes in case there are friends who are experiencing these. 1- First of all, I used Python 3.10 version. I couldn't do it with 3.12. I installed dev with sudo apt-get install python3.10-dev command of the same version. It didn't work with any other version. 2- When I proceeded according to your explanations, I was getting 502 bad gateway error error at the end. Nginx could not access the relevant files. I saw this in the Nginx logs. after this stage, I solved the problem by taking the udoms user and the nginx user to the same group. But it took me a long time to solve this. After all, I am not a system administrator or I don't have much linux knowledge. I used sudo usermod -g www-data udoms command to do this. I thank Tony again...
Althougth, the first point nowadays works, because I am running at python 3.12. And succesfully installed the app python3.12-dev. And as you said, there was an 502 bad gateway because of lack of permissions of my to the primary group of www-data. I was thinking about these command: gpasswd -a www-data But it didn't and yours exactly worked. I dont know why but it seems to be the primary group as a instead of just adding the to the group . It seems weird error, because I do this command in another server(same type ubuntu) and works perfectly.
Hi. This looks like a single server for the website. Isn't that vulnerable if something happens to hardware, connection or when maintenance? Is it possible to have two servers working in different locations for the same website?
I see what you're saying about having multiple applications on a single server. Yes technically I guess you're right that if the server is compromised, every application is vulnerable. Choosing to host on separate servers could slow down an attacker, but probably not stop him entirely if he's determined enough. Always remember that anything connected to the internet is never truly secure. It's certainly possible to host different applications on different servers for the same website. This of course would add in network latency when the servers communicate with each other. Honestly I don't have much experience in this realm, but that's just my 2 cents :)
Subscribed, thank you for this. Still not 100% clear on why nginx is needed here - I heard your explaination in the video that nginx is "better" at handling static files, but that didn't really sound like concrete answer. Would you be able to expand on that a little bit? Thanks! Side question - the static files that are generated with collectstatic, what are those? Just defaults that get shipped with Django? Thanks again for this great tutorial
we really loved your video and follow all steps and successfully deployed it on our cloud server can you please make a video how we can run django app on docker ?
Are you familiar with Django models? docs.djangoproject.com/en/3.1/topics/db/models/. It's a way of abstracting database interaction in Django. That would be my suggestion. You'll still need a database of some sort like MySQL. I will have a video on this topic in the next few months :)
I found this video after discovering your current Django videos. Is this video still relevant today or do you plan to make a new video on deployment with Docker?
Hi! I have a issue.. Unitl uwsgi --http :8000 --module microdomains.wsgi, everything is fine but when i make a nginx file and make everything like in tutorial, when i download media.gif and make collectstatic then try to go ip/media/media.gif return 404 not found. uwsgi --socket mysite.sock --module mysite.wsgi --chmod-socket=666 i have a 502 gateway, i tried with 664 socket, without socker, i research all internet and cant find resolve
after running the uwsgi --socket (socketname).sock --module (modulename).wsgi --chmod-socket=666 my nginx still having bad gateway. what could be the issue?
Hi tony, this was very good tutorial. if nginx is on a different server than wsgi/django can you use a socket for communication or do I have to use http?
when i run my django project it give me errorr django.db.utils.OperationalError: connection to server at " ", port 5432 failed: Connection refused (0x0000274D/10061) Is the server running on that host and accepting TCP/IP connections? can u please solve my problem
Wonderful tutorial thank you. On step 5 I got a 403 forbidden when trying to acces the media, I reviewed and everything appears to be correct. What can I do?
Hi Tony. Great tutorial, I really appreciate it. You were such a big help. Does this uwsgi replace gunicorn? I'm still confused about the gunicorn. Do I need to install Gunicorn for production?
Thank you for the video. With respect, I think uWSGI doesn't call the "Django backend" but the "Django app". And that "Django app" does not call Python -- rather, it is interpreted by the Python interpreter. Hope this clears up any confusion for the viewers.
Hi, I have a question. Does this method works with Plesk panel on Ubuntu LTS (Apache web server and nginx as proxy server)? Actually, I have plesk panel and couldn't run Django app with Postgre SQL database (database has no issue, it works fine) Please record a video about plesk panel for Django installation...
Hi there, Tony! Could you please explain how the socket is created? What creates it and at which point? Or does it need to be created manually somehow?
Hello Tony, I hope you're going well ! First, thank you so much for your time and this tutorial. So I've an issue, please can you explain me what I wanna do to get mysite.sock ? I'm following your tuto and you don't tell any worlds, how you have microdomains.sock in your NGINX conf file. Thank you so much for all.
I need help. I dont understand how the NGINX config file is supposed to look like. I'm running this on a pi. I can't get past the NGINX part. What path do I use for my upstream django line? What about the server_name line? Im just using my IP, not a domain?
@@TonyTeachesTech Thanks. In the end I was able to get it working after some trouble shooting. I just went though your other videos on getting SSL certs and getting django production ready. All excellent vids. I just have one question though, How exactly would we restart or stop the server if we wanted to? Whats the difference between using NGINX (/etc/init.d/nginx restart) or what you used (systemctl restart emperor.uwsgi.service)? Thanks so much!
@@TonyTeachesTech I actually have one more question for you, if you don't mind. I am unable to access the production site from within my own network. I totally understand why, due to the way NAT and port forwarding works, and I have been using a VPN to actually reach my site. You seem to be able to reach your site from within the same network. How do you go about this?
@@TonyTeachesTech worked like a charm, also embedded SSL using certbot, just a heads up letsencrypt won't work on Ubuntu anymore, use certbot, it's totally automatic with the configuration you provided, also I'll be spamming this video bc it's goes up straight to the point!! Thankss
Man! You just made our entire life! We were struggling for the past 3 days just to get a Django website up and running! Thanks for being the guardian angel.
Sure thing. Very happy to help ya out
Tried configuring a server over several days with no real success. This video was really helpful. Have being able to get the server running. Thanks
Thanks! I'd give more if I had more! A tutorial on point. Explanation on point. Everything was clear and perfectly explained.
Wow, really appreciate it Karim! Happy to hear it. More Django tutorials to come this year :)
Fantastic! After two nights of trying to get django to work with nginx or apache this was extremely clear and to the point. Thanks!
Glad it helped!
i am still suffering
One of the best tutorials out there. I am saying that after trying a dozen of them with no results
Thank you very much!
For anyone having trouble installing uwsgi or any other package for that matter into ur virtual enviroment, make sure the user ur working with owns the virtual enviroment. Do not use sudo, cause you really dont want any of these packages to be installed globably. Also, uwsgi depends on gcc, python dev and wheels. Hope this helps anyone stuck. (any packaged with pip)
I just deployed my api that i will use in my undergrad research. Thank you so much. Great help. Will definitely watch again to get this completely.
I bow to you. You made something that felt incredible difficult almost to easy 👍
Thank you very much. So happy you got value from it :)
At present money is everything...but you provide this video free.....
Thanks you so much...and
Love from Bangladesh...❤️❤️❤️
You are most welcome. Cheers
This is THE online resource to get a Django project deployed! I can't thank you enough, Tony, I have been struggling with this for days!
No problem Teddy
The best django deployment tutorial i found, i plan to use docker and google cloud run for my deployment, but i just want to test the server deployment to learn some details about how everything works together, thanks a lot, works like a charm
Glad I could help!
I have been trying lot's of time but can't help me sir .. always show 502 error
did u fix the error??
Thank you so much! It's so much easier when someone explains step by step the documentation!
Glad it was helpful!
Thank you very much, this tutorial solved my troubles with deploying django under nginx on Debian 11
This literally could not have come at a better time! This is exactly what I was looking for. Liked and subbed!
Appreciate it! Thanks for letting me know. I spend a lot of time on my videos and never know if people will find them valuable :)
Fantastic and detailed. This worked for me where others did not. Thank you
Best video on the internet. Thank you so much for explanation. ✌️
So nice of you. Thanks!
Hi Tony. Great tutorial, I really appreciate it!
I want to add a little thing, perhaps someone is running into the same problem. When setting the uwsgi.ini file (around 28:00) , I had to comment out the ' home' line for it to work.
Logs showed an error when mapping the PYTHONHOME, commenting that line out solved the issue.
Thanks for sharing. This will hopefully help out others
i almost wated 4 days in it
u saved my life bro
thank u
You're welcome
you're monster brother... saving an enthusiast in python/django...thanks
Sure thing!
2022 still perfectly working. great video. It's really helpful. Thank you so much bro!
체크 해야 할 부분
33:01 systemd 실행
still a very valuable information! I am grateful for finding this tutorial! Thanks a lot for sharing your expertise with us!!
Hello, after 2 days of struggling with this installation, I found your video and explanations. First of all, thank you very much.
Although I used all the parameters such as user and domain as yours, I encountered some errors. I wanted to write some notes in case there are friends who are experiencing these.
1- First of all, I used Python 3.10 version. I couldn't do it with 3.12. I installed dev with sudo apt-get install python3.10-dev command of the same version. It didn't work with any other version.
2- When I proceeded according to your explanations, I was getting 502 bad gateway error error at the end. Nginx could not access the relevant files. I saw this in the Nginx logs. after this stage, I solved the problem by taking the udoms user and the nginx user to the same group. But it took me a long time to solve this. After all, I am not a system administrator or I don't have much linux knowledge. I used sudo usermod -g www-data udoms command to do this.
I thank Tony again...
Thank you so much, this needs to be at the top comments, it works now smoothly
Althougth, the first point nowadays works, because I am running at python 3.12. And succesfully installed the app python3.12-dev. And as you said, there was an 502 bad gateway because of lack of permissions of my to the primary group of www-data. I was thinking about these command:
gpasswd -a www-data
But it didn't and yours exactly worked. I dont know why but it seems to be the primary group as a instead of just adding the to the group .
It seems weird error, because I do this command in another server(same type ubuntu) and works perfectly.
Thank you man, still the best video… with the best explanation… really appreciated
Glad you liked it!
Good job, keep the videos coming. Thanks for your efforts.
Thanks, will do!
Thank you so much. Explained a complicated topic very clearly.
You are welcome!
thx for this video. i am struggeling with apache and now use nginx.
Good luck!
thanks Tony, please can you make a video on django and docker deployment?
Excellent tutorial. Thankyou.
Hi. This looks like a single server for the website. Isn't that vulnerable if something happens to hardware, connection or when maintenance? Is it possible to have two servers working in different locations for the same website?
I see what you're saying about having multiple applications on a single server. Yes technically I guess you're right that if the server is compromised, every application is vulnerable. Choosing to host on separate servers could slow down an attacker, but probably not stop him entirely if he's determined enough. Always remember that anything connected to the internet is never truly secure.
It's certainly possible to host different applications on different servers for the same website. This of course would add in network latency when the servers communicate with each other.
Honestly I don't have much experience in this realm, but that's just my 2 cents :)
Subscribed, thank you for this.
Still not 100% clear on why nginx is needed here - I heard your explaination in the video that nginx is "better" at handling static files, but that didn't really sound like concrete answer. Would you be able to expand on that a little bit? Thanks!
Side question - the static files that are generated with collectstatic, what are those? Just defaults that get shipped with Django?
Thanks again for this great tutorial
:) To avoid ERROR : failed to build wheel
install wheel package in your project venv
>> pip install wheel
note: before that upgrade pip and setuptools
🙏
You will win the NOBEL PEACE Prize one day. Thank you
Can you please make one video on deploying flask with uwsgi , nginx .
Thanks :)
Hi, sorry I'm not familiar with flash
we really loved your video and follow all steps and successfully deployed it on our cloud server can you please make a video how we can run django app on docker ?
Thank you. Genuinely, THANK YOU!
You're welcome!
I am truly greatful for this! Thank you! ☺️
You're so welcome!
ur the one that I was looking for, thanks bro, do u have any tutorial on how to connect Django with a database like MySQL?
Are you familiar with Django models? docs.djangoproject.com/en/3.1/topics/db/models/. It's a way of abstracting database interaction in Django. That would be my suggestion. You'll still need a database of some sort like MySQL. I will have a video on this topic in the next few months :)
I found this video after discovering your current Django videos. Is this video still relevant today or do you plan to make a new video on deployment with Docker?
Thanks for the upload. Excellent tutorial 👍 are you using virtual box for local development?
Thank you! Yes, sometimes, I just made a video about this here th-cam.com/video/wqm_DXh0PlQ/w-d-xo.html
thank you for such helpful content
Thank you, Tony! This tutorial is very useful!
You're very welcome!
Thank you very much for this through reality-show-like tutorial! Much helpful! :-)
Yes bro, It's really helpful. Thank you man
Always welcome
But why am I only finding you now? because! Good!
Happy ya found me :)
Thanks a lot. Amazing tutorial.
One quick question. How to restart uwsgi whenever there is a change in the code?
I typically restart the emperor service
systemctl start emperor.uwsgi.service
Thanks for making the video. Subbed.
Much appreciated Umar!
Hi! I have a issue..
Unitl uwsgi --http :8000 --module microdomains.wsgi, everything is fine but when i make a nginx file and make everything like in tutorial, when i download media.gif and make collectstatic then try to go ip/media/media.gif return 404 not found.
uwsgi --socket mysite.sock --module mysite.wsgi --chmod-socket=666 i have a 502 gateway, i tried with 664 socket, without socker, i research all internet and cant find resolve
I have the same issue. I can't fix it since last week, with the whole power of the internet...
did you fix it. İ have the same problem
Same here guys please provide info if got any information
me choque con el mismo problema... permiso denegado.. y no encuentro la solución correcta
after running the uwsgi --socket (socketname).sock --module (modulename).wsgi --chmod-socket=666 my nginx still having bad gateway. what could be the issue?
Same issue here. Did you ever resolve the problem?
Awesome tutorial man, love your pedagoc approach. Any chance you could update this to be using Docker and docker-compose?
Thanks Alexander! Right now I'm clueless when it comes to Docker. I plan to look into it next year
Excellent tutorial. Thank you :)
You're very welcome!
thankyou so much .. you explained every step very well
You are welcome 😊
Hi tony, this was very good tutorial. if nginx is on a different server than wsgi/django can you use a socket for communication or do I have to use http?
I believe sockets are only local, so you would have to use http
You Explained Everything very well, thanks
You’re welcome!
I really love you man. So many thanks!
Happy to help!
What should be content and permission of .sock file mine is empty ? error i am getting permission denied when while connecting to upstream client
Thank you so much brother, really helped me. :)
Thanks a lot, Tom this was really helpful
You're welcome. It's Tony btw :)
Excellent Explanation!!
is installing and configuring Gunicorn instead of uWSGI the same?
AWESOME TUTORIAL!
Thanks!
when i run my django project it give me errorr django.db.utils.OperationalError: connection to server at " ", port 5432 failed: Connection refused (0x0000274D/10061)
Is the server running on that host and accepting TCP/IP connections? can u please solve my problem
It sounds like the port is closed
I'm still getting 502 bad gateway after step 6 in the blog post -- has anyone else had issues with this?
Maybe see if this helps th-cam.com/video/hYVriHb43wU/w-d-xo.html
@@TonyTeachesTech can you help us please, Im getting the same error, I saw the video but no clue
Django doesn't work on publlic IP, but Nginx works. Where i can search for help?
you made my day dude :)
Happy to hear that 😁
Thank you so much, you were such a big help!!
Glad it helped! All the best Daniel
Thank you sooo much for the tutorial!!
No problem 😊
Wonderful tutorial thank you.
On step 5 I got a 403 forbidden when trying to acces the media, I reviewed and everything appears to be correct. What can I do?
This should help th-cam.com/video/01T5JJGW4_c/w-d-xo.html
Buen material Antonio!
ca you make one about connecting django to oracle autonomous database please?
I haven't worked with oracle autonomous db
Muchas gracias muy completo tu video y me ayudo a reforsar conceptos (Y)
No me funciona en ubuntu 22.04! pipipi
Hi Tony. Great tutorial, I really appreciate it. You were such a big help. Does this uwsgi replace gunicorn? I'm still confused about the gunicorn. Do I need to install Gunicorn for production?
uWSGI is an alternative to gunicorn
Thank you so much for the video. A question, I have an environment variable file ".env" that includes key/value pairs. How can I use them in uwsgi?
I don’t know sorry
Thanks for this tutorial.
You're welcome!
awesome
:)
So after this, I just have to copy my project to the server and that's it?
you basically just now created the Django project, how come the localhost got linked with your domain?
Why do we need to let Django know where the static files are? Aren't the nginx the one which serves static & media files?
Thank you for the video. With respect, I think uWSGI doesn't call the "Django backend" but the "Django app". And that "Django app" does not call Python -- rather, it is interpreted by the Python interpreter. Hope this clears up any confusion for the viewers.
Thanks for clarifying William :)
Hi, I have a question. Does this method works with Plesk panel on Ubuntu LTS (Apache web server and nginx as proxy server)? Actually, I have plesk panel and couldn't run Django app with Postgre SQL database (database has no issue, it works fine) Please record a video about plesk panel for Django installation...
What if it is in prod? Should same step be applied?
this what i need to understand deployment of django web app in web
Great!
mine stuck at "starting uWSGI Emperor" it didn't do anything
Wow, thanks dude!
You bet!
Excellent dude
Thank you! Cheers!
Hi there, Tony! Could you please explain how the socket is created? What creates it and at which point? Or does it need to be created manually somehow?
The socket is automatically created when you do run the uwsgi command
@@TonyTeachesTech That's the last piece missing for me. Thank you. :)
Hi Tony, I was wondering if this is compatible with Dreamhost or where Dreamhost comes into play in this stack? Thanks!
Thanks Tony for your hard work. I would like to know if the config can work in local network. I have my project and I want to run in local network
Yes I don't see why not. You'd have to go to the IP address instead of a domain name
good
Thanks
Thank you so much!
Hello Tony, I hope you're going well ! First, thank you so much for your time and this tutorial.
So I've an issue, please can you explain me what I wanna do to get mysite.sock ?
I'm following your tuto and you don't tell any worlds, how you have microdomains.sock in your NGINX conf file.
Thank you so much for all.
What is the font? Looks amazing.
I had set some environment variables. but not getting that after start up uWSGI when the system boots.
Hmm not sure why
Thank you very much broo
Welcome
I need help. I dont understand how the NGINX config file is supposed to look like. I'm running this on a pi. I can't get past the NGINX part. What path do I use for my upstream django line? What about the server_name line? Im just using my IP, not a domain?
Take a look at the Nginx config file here tonyteaches.tech/raspberry-pi-wordpress/
@@TonyTeachesTech Thanks. In the end I was able to get it working after some trouble shooting. I just went though your other videos on getting SSL certs and getting django production ready. All excellent vids. I just have one question though, How exactly would we restart or stop the server if we wanted to? Whats the difference between using NGINX (/etc/init.d/nginx restart) or what you used (systemctl restart emperor.uwsgi.service)? Thanks so much!
@@TonyTeachesTech I actually have one more question for you, if you don't mind. I am unable to access the production site from within my own network. I totally understand why, due to the way NAT and port forwarding works, and I have been using a VPN to actually reach my site. You seem to be able to reach your site from within the same network. How do you go about this?
Thank you so much....
You're welcome Joshua
23:25 I think it is due to port forwarding ?
Thank you Tony anyway, I been looking for video like this for a year.
As you said info around all the internet either not [clear] or not [complete]
you need wheel to stop the uwsgi error message, >> pip install wheel
Roger that
I've been through countless videos and countless times i've terminated and relaunched EC2 instances, let's see whether you take the bid or not
How'd it go?
@@TonyTeachesTech worked like a charm, also embedded SSL using certbot, just a heads up letsencrypt won't work on Ubuntu anymore, use certbot, it's totally automatic with the configuration you provided, also I'll be spamming this video bc it's goes up straight to the point!! Thankss
@@sanxchepsharma7149 I'm happy to hear that! Best of luck to you :)