Django | Server Setup (WSGI, Gunicorn, Nginx)

Поділитися
Вставка
  • Опубліковано 5 вер 2024
  • A tutorial on how a Django project runs in development and production environments.
    I also show how to run a Django project using a WSGI server (Gunicorn) and a web server (Nginx).

КОМЕНТАРІ • 290

  • @Snakes.StartToSing
    @Snakes.StartToSing 3 роки тому +161

    its funny that such an important concept its never explained in other channels, they can talk about django all day long, but fail to explain the professional way of deploying apps

    • @ashir3730
      @ashir3730 2 роки тому +4

      That's 1000000000000000....% correct. Come Back Mam, you have things that no one has.

    • @serious6037
      @serious6037 2 роки тому +1

      100% bro. amen to that.

    • @sauravgupta7415
      @sauravgupta7415 2 роки тому +5

      Because they don't know themselves.

    • @alfagroupkz
      @alfagroupkz Рік тому

      😆🤌🏻

    • @MrRahul15937
      @MrRahul15937 Рік тому +1

      Digital ocean has blog post on it.

  • @winningtech5
    @winningtech5 2 роки тому +60

    Never seen a django deployment tutorial as explanatory as this. I was totally struggling thanks!!

  • @gedeoneyasu6811
    @gedeoneyasu6811 3 роки тому +55

    Thanks, great video! I am learning Django deployment and always get afraid when I hear the terms Nginx and Gunicorn but you made them very clear now!

    • @djangoroad
      @djangoroad  3 роки тому +7

      I'm so glad you understand them better now :)

    • @ashir3730
      @ashir3730 2 роки тому

      @@djangoroad read: you are looser. Do you know why you stopped... creating the content? I was going to write this but you are not my slave. !00 and 2 o/o. that's your choice great videos mam. I pray you will come back not for us but .....

    • @aliyusulaiman8188
      @aliyusulaiman8188 5 місяців тому

      Hahaha been there

  • @gelismissuriyeli4440
    @gelismissuriyeli4440 2 роки тому +7

    I've watched 10 videos on this topic so far and some of them were 50 mins long "in the name of explaining in details" but this brief and well done video was the best and the clearest so far.

  • @laxmandesai573
    @laxmandesai573 2 роки тому +5

    Wait, I think you dropped this 👑

  • @yoip1234
    @yoip1234 5 місяців тому

    Such a simple and clear tutorial ! I have not seen another Django tutorial that explains the concept in such a clear way. Thank you for creating this video.

  • @developer7607
    @developer7607 Рік тому

    Thank you from South Korea! I have never seen such a easy-to-understand lecture to get the concept of web server❤

  • @jtgasper4621
    @jtgasper4621 2 роки тому +7

    Great content explained in such an easy-to-understand way. I loved how you broke down the concepts then showed them in practice.

  • @markgacoka9704
    @markgacoka9704 2 роки тому +2

    This is the simplest explanation I have found thus far. Thank you so much!

  • @vladventura1928
    @vladventura1928 3 роки тому +4

    I love you, literally saved me from hours of endless headscratching; I'm new to this so its still pretty daunting to say the least :/

  • @danryan5044
    @danryan5044 Місяць тому

    Clear and simple instructions. Still a great tutorial in 2024!

  • @peterg4524
    @peterg4524 Рік тому +1

    I had been struggling following the gunicorn docs and understanding the relation between Nginx-Gunicorn-Django, then I found your video that put it all together very succinctly. Thank you for the time and effort you took to make the video and post it on you-tube. Your effort has been greatly appreciated and helped me greatly. Thank you.

    • @djangoroad
      @djangoroad  Рік тому

      Thanks for the comment :) I'm glad you found the video helpful.
      Goodluck!

  • @clementidemudo6006
    @clementidemudo6006 Рік тому

    so I'm watching this tutorial 2 years later, and guess what, my testimony still resonates with the many appraisal comments. good work @django road

  • @hackvlix
    @hackvlix Рік тому +2

    Nice tutorial. Complete, to the point, and, most importantly, correct.

  • @python360
    @python360 Рік тому +5

    This tutorial is bang on the money. I've followed an hour long video and not got it working, this last 9 mins and DOES work. Brilliant. If you get a chance could you do one on setting up SSL and port 443 with Django on a production site?
    Thank you Dot JA 🙂

  • @alaouiamine3835
    @alaouiamine3835 10 місяців тому

    Finally a tutorial speaking human language
    Nicely explained 🙏

  • @jordanmuller2536
    @jordanmuller2536 21 день тому

    It's so rare that I click like on a video, but wow this was a great video. Had to go seerching in my apps UI to even find the button. Thank you for the explanation.

  • @outright99
    @outright99 3 роки тому +2

    OMG... the way you explained this is so clear... Many thanks really. Now investigating to add more security to the site! Cheers!

  • @fusionfuryx
    @fusionfuryx Рік тому

    In my organisation, our huge django application is configured with both gunicorn and nginx as web server. I had so many confusions in the configuration coupling. Now I have a clear picture after watching your explanation. And one more thing, I would like you to make a similar video on nginx proxy server configuration for load balancing django application. As the user base grows, proxy server is the way to scale with proper cpu utilisation.
    Great video by the way. Keep up the good work. Thanks

  • @staslis1924
    @staslis1924 9 місяців тому

    God bless you! 3 years old video and still the best one over YT))

  • @anilkumarsahoo909
    @anilkumarsahoo909 2 роки тому +1

    Thanks mam, my first deployment done seamlessly.

  • @KrishnaManohar8021
    @KrishnaManohar8021 3 роки тому +5

    Hope to cover this topics too:
    Django with lambda, Scaling
    Django with Docker, Kubernet
    Django with S3 Bucket
    Django with RDBMS (handle/Fetch data from the different database)
    cover with AWS.

  • @harrylai5233
    @harrylai5233 3 місяці тому

    Very good, it is the easy way that you show about how to deploy django app.

  • @lexxluey
    @lexxluey Рік тому

    exactly what I was looking for. I have to install Django on a server on an intranet. this came in very handy

  • @yourlinuxguy
    @yourlinuxguy 11 місяців тому

    Thankyou very much for making this fantastic video, this video helped me setup my first website with django, still relevant after 2 years, thanks.

  • @eagleofsharm
    @eagleofsharm 9 місяців тому

    I've just come to your channel, great content, but believe there is a lot u can offer to the community, keep It up.🥰

  • @udbhavdave
    @udbhavdave 3 роки тому +2

    your content is great buddy, just keep patience and continue making useful videos, and you will have huge reach. Thanks again, looking forward for more django and web development related videos.

  • @amiralikhan
    @amiralikhan 10 місяців тому

    thank you very much - جزاکم اللہ احسن الجزاء

  • @matheusandrade1059
    @matheusandrade1059 7 місяців тому

    thank you so much, your videos are amazing, simple and direct to the point with clear explanation.

  • @javalex561
    @javalex561 9 місяців тому

    Excellent video. Please make one on how to deploy multiple django sites on 1 server using this.

  • @neekawsaur
    @neekawsaur 3 роки тому

    Thank you so much for making this video. After days of me constantly failing, you realy helped me out!

  • @agelosnm
    @agelosnm 3 роки тому +1

    Great video! Simple deomonstration of the tool :)
    One note: in my case, isntead of "root" I needed "alias" for the static files (location /static/)

  • @ProjectXH
    @ProjectXH Місяць тому

    Marvelous explanation!

  • @arabboymamadaliyev6565
    @arabboymamadaliyev6565 3 роки тому

    Thanks.It is so easy understandable for me than other videos.

  • @user-he4st2ro5h
    @user-he4st2ro5h 2 роки тому +1

    Wow, that was a masterpiece of explanation! Thank you 🙏

  • @lucaslourencoschimidt8480
    @lucaslourencoschimidt8480 10 місяців тому

    Incredible! Super intuitive and well explained. Thank you!!!!

  • @etsw
    @etsw Рік тому

    It was a very direct explanation and simple, but it's straight to the point. I liked it. Thank you :)

  • @jerry5955
    @jerry5955 2 роки тому

    Thank you for this tutorial. I was struggling to get the final piece with gunicorn setup "pythonpath" and "command" vars were missing. I kept scratching my head as to why the workers weren't spawning. You awesome!!!!!

  • @chessinaglimpse9899
    @chessinaglimpse9899 4 дні тому

    This was so helpful, thank you so much

  • @shadowgag4526
    @shadowgag4526 2 місяці тому

    This was PEAK content! Very well explained. Just one question, I know I'm very late, but why did we need to create a specific route for /static/ in nginx ? What if we don't give it, django anyways is going to handle those right, after we run `collectstatic`?

  • @lofmaan
    @lofmaan Рік тому

    really nice tutorial, looking forward to more videos

  • @philippbraun9306
    @philippbraun9306 3 роки тому

    Thx a lot! Thats a great short video that covers the basics needed 👍👍

  • @tts1958
    @tts1958 3 роки тому +2

    I get a 502 Bad Gateway error. I tried to fix it for the last couple of days and I can't. Does anyone have any idea how to solve it?

  • @alaminbijoy1027
    @alaminbijoy1027 3 роки тому +1

    Hey make more of these deployment type videos. They are super helpful

  • @subinkv6849
    @subinkv6849 7 місяців тому

    Easy to understand great presentation.

  • @kenwakeyboard
    @kenwakeyboard 7 місяців тому

    Also if you are on a VPS or similar, you need to allow port 8000 on the provider side, e.g. change AWS EC2 inbound rules for your instance to allow custom tcp port range 8000. Otherwise you will keep getting connection refused.

  • @nickheyer
    @nickheyer 2 роки тому +1

    Hi, this is an awesome video! If possible, you should follow this up with how you would integrate certbot.

  • @FullRGB
    @FullRGB 3 роки тому

    One of the best videos I've ever watched. Thanks!

  • @maiadasilvapereira4633
    @maiadasilvapereira4633 8 місяців тому

    Thank you very much It is very useful Tutorial

  • @soffer
    @soffer 3 роки тому +1

    This is excellent, thanks for the tutorial. Got it working on an AWS EC2. Not sure why I did the docker version of this tutorial before this one but whatever

    • @Poo1199-c1o
      @Poo1199-c1o 3 роки тому +1

      Hi , did you add ip of EC2 in allowed host ??

    • @soffer
      @soffer 3 роки тому

      @@Poo1199-c1o Yes. It's not good practice but I think you can do ['*'] to allow any host also

    • @Poo1199-c1o
      @Poo1199-c1o 3 роки тому

      @@soffer I am getting 502 error while accessing the instance IP.. do you know how that can be resolved?

    • @soffer
      @soffer 3 роки тому +2

      @@Poo1199-c1o Sorry I am not an expert. That makes me think nginx is running and trying to hit gunicorn but gunicorn has an issue. is gunicorn running? i believe it should be: user clicks goes to your web page -> nginx gets request -> request passed to gunicorn -> something goes wrong and 502

  • @EchoVids2u
    @EchoVids2u 2 роки тому

    This was super insightful! Thank you so much. You're the best.

  • @slog7590
    @slog7590 2 роки тому

    Thankyou so much , for such wonderful explaination.

  • @MrRynRules
    @MrRynRules Рік тому

    Thank you so much, it was so well explained!

  • @denisjean-bastien1253
    @denisjean-bastien1253 Рік тому

    You are so awesome, it's so clean, thank you one million times !

    • @denisjean-bastien1253
      @denisjean-bastien1253 11 місяців тому

      I'm trying so hard to setup Django with OpenLiteSpeed and his module LSAPI. If you're looking for a new tutoriel 😅

  • @Randomguy-zv3tv
    @Randomguy-zv3tv Рік тому

    explanation is so clear, thank you

  • @middleclass3782
    @middleclass3782 3 роки тому

    Thanks a lot. That was really helpful. Straight to the point.

  • @nickolasmaslow7041
    @nickolasmaslow7041 Рік тому

    thank you very much, this is the best explanation

  • @rajeshs3771
    @rajeshs3771 3 роки тому

    Excellent. Well appreciated. Simple and elegant. ❤️ from Chn Greater Bharat

  • @fahadKhanDev
    @fahadKhanDev 3 роки тому

    Great tutorial I love your teaching method

  • @hasithaeranga5589
    @hasithaeranga5589 Рік тому

    very clear and onto the point

  • @fergusfariuson3910
    @fergusfariuson3910 3 роки тому

    Super. Thanks from Uzbekistan

  • @valittheboss
    @valittheboss 6 місяців тому

    Great video, thank you!
    However there's a small mistake at the end (I think), in the Nginx config where you're using "root /home/ubuntu/static",
    that wouldn't work because it will resolve to home/ubuntu/static/static
    I suppose it worked at the end because debug was still set to True

  • @lolcraft2067
    @lolcraft2067 3 роки тому

    Thank you, the best tutorial on the topic

  • @ahmedshalaby1878
    @ahmedshalaby1878 10 місяців тому

    Perfect, thanks alot!
    But, i have a question regarding deploying new services on the same server.
    Should i do it like that:
    1. Deploy new django service in new container qith gunicorn.
    2. Edit nginx service to serve both old and new services.

  • @imhan7026
    @imhan7026 8 місяців тому

    wow, perfect tutorial, thank you so much

  • @JoaoCarlosCvel
    @JoaoCarlosCvel 11 місяців тому

    perfect explained, thank you!

  • @alizafari8729
    @alizafari8729 3 роки тому

    Concise and clear, thank you.

  • @vitali1959
    @vitali1959 2 місяці тому

    Thanks, great video!

  • @manho2965
    @manho2965 2 роки тому +3

    thanks for your video. I have an error "No module named "myproject.wsgi". Any idea to fix it?

  • @arashsayareh7728
    @arashsayareh7728 3 роки тому

    Very very obvious and useful. Thanks!

  • @huzaifasserugo4357
    @huzaifasserugo4357 9 місяців тому

    thank you so much, I followed a digital ocean tutorial and couldnt get my app to be served, I am wondering why this very simplified approach gets the job done. Is this all the setup I have to do? what are the next steps? thank you so much.

  • @mjennings061
    @mjennings061 3 роки тому +2

    A slick tutorial, well done! Are media files treated the same as static files or is there another configuration needed for production?

    • @djangoroad
      @djangoroad  3 роки тому

      Thanks for the feedback! Media files are treated same as static, you can specify the location in the Django configuration as well as the Nginx config. Depending on the traffic you receive to your web app, you might also want to look into S3 for storing this type of content.

  • @SUMITKUMAR-hl4fp
    @SUMITKUMAR-hl4fp 3 роки тому

    Love from India. Keep going ❤️

  • @AliMohammed-zn5ih
    @AliMohammed-zn5ih 3 роки тому

    very simple and useful 😸 💚💚
    Keep going ☺️

  • @robertarustamyan5168
    @robertarustamyan5168 4 місяці тому

    Thank you for explanation

  • @rafaelcosquiere
    @rafaelcosquiere 2 місяці тому

    Nice video, thanks.
    I just wonder what’s the difference or pros and cons between serving statics with WhiteNoise vs serving statics with web server.
    Although I guess in production for real projects, statics will be serve by a cdn, right ?

  • @dr99tm23
    @dr99tm23 3 роки тому

    Clear tutorial ,Keep going ,thanks 👍

  • @kuglatec
    @kuglatec Рік тому

    This is just perfect! Thanks alot!

  • @farhadkabir1321
    @farhadkabir1321 3 роки тому

    very simple and informative

  • @AllthingsFoodieTX
    @AllthingsFoodieTX 2 роки тому

    Good job 👍 simple and effective

  • @agpark-yg8vs
    @agpark-yg8vs 4 місяці тому

    thank you!!! you literally save my life lol

  • @liorbm1
    @liorbm1 3 роки тому

    This is really great !
    Thank You !

  • @louisdevitry8240
    @louisdevitry8240 3 роки тому

    Thanks! Great explanation 🔥

  • @finn9233
    @finn9233 2 роки тому

    this finally worked thank you.

  • @Eduardo_C
    @Eduardo_C Рік тому +1

    At 5:05, what and from where did you copy and paste? I am using a Mac and want to get the correct path for both the `command` and `pythonpath` variables. Thank you!

  • @arcsin4083
    @arcsin4083 5 місяців тому

    Thank you for video!
    But what is your IP in the Nginx config and why do you need to specify it there explicitly?
    I thought it can be some kind of alias that refers to the primary netrowk interface and assigned IP to it by the network provide.

  • @hamoudguicheniti3949
    @hamoudguicheniti3949 3 роки тому

    Thank you so much, great job!

  • @angeldelgado6193
    @angeldelgado6193 3 роки тому

    Thanks from Venezuela!!

  • @ferdiansahgg
    @ferdiansahgg 2 місяці тому

    thanks this work with ubuntu 22.04 UEFI on alibaba cloud, with django 5.0

  • @multimediaceron2742
    @multimediaceron2742 11 місяців тому

    Great tutorial, thanks a lot

  • @feluve
    @feluve Рік тому +1

    Do you know if, once you place the static files in the /static/ folder, you have to set some permissions?

  • @anandumdharan6283
    @anandumdharan6283 2 роки тому

    hey thanks a ton...this was what i needed

  • @amal3227
    @amal3227 2 роки тому

    for anyone who might be running into the same problem as I am. I don't know but placing the complete static directory path in my settings.py did not work ( I reference static files using the static tag, that might have something to do with it)
    what finally worked for me is settings.py:
    STATIC_URL = '/static/'
    and in the nginx configuration
    location /static/ {
    root {my project path without the '/static/' at the end };
    }

  • @enricosaccheggiani3192
    @enricosaccheggiani3192 2 роки тому

    Thanks a lot for this interesting tutorial

    • @enricosaccheggiani3192
      @enricosaccheggiani3192 2 роки тому

      Excuse me I am struggling to set up permanently a web site in Django with supervisor.
      The site works well when it's started manually, but when I use supervisor it does not work.
      Do you have any video that explains how to set the site permanently?
      Thanks in advance

    • @enricosaccheggiani3192
      @enricosaccheggiani3192 2 роки тому

      Now it works well.
      Thanks for the interesting video

  • @alaminbijoy1027
    @alaminbijoy1027 3 роки тому

    wow! straight to the point

  • @Indrajeet307
    @Indrajeet307 3 роки тому

    Informative video, thank you

  • @Addybhoot93
    @Addybhoot93 2 роки тому

    Perfect you explained the concept very easily in plain English. Can I add the Postgres template to my project structure?

    • @djangoroad
      @djangoroad  2 роки тому

      Yeah you can, I think I have videos on that topic in this channel.

  • @yannickpezeu3419
    @yannickpezeu3419 3 роки тому

    crystal clear. Thank you !

  • @shraveenb.s3983
    @shraveenb.s3983 Місяць тому

    Once you make it work on nginx. Will I be able to access it with other devices using my wifi network, by typing in the public IP?

  • @crcacom
    @crcacom 2 роки тому

    Thanks. I ll try Gunicorn