Django | Server Setup (WSGI, Gunicorn, Nginx)

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ย. 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).

ความคิดเห็น • 291

  • @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 ปีที่แล้ว +61

    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 👑

  • @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.

  • @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 :/

  • @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

  • @developer7607
    @developer7607 ปีที่แล้ว

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

    • @djangoroad
      @djangoroad  ปีที่แล้ว +1

      Thanks for the support :)

  • @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!

  • @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.

  • @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.

    • @djangoroad
      @djangoroad  3 ปีที่แล้ว +3

      Nice ideas! Thanks

    • @SwapnilPhulse
      @SwapnilPhulse 3 ปีที่แล้ว +1

      Great points! A resource discussing this would be immensely helpful.

    • @KrishnaManohar8021
      @KrishnaManohar8021 3 ปีที่แล้ว

      @@SwapnilPhulse +1

  • @markgacoka9704
    @markgacoka9704 2 ปีที่แล้ว +2

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

  • @alaouiamine3835
    @alaouiamine3835 10 หลายเดือนก่อน

    Finally a tutorial speaking human language
    Nicely explained 🙏

  • @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 🙂

  • @jordanmuller2536
    @jordanmuller2536 22 วันที่ผ่านมา

    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.

    • @djangoroad
      @djangoroad  21 วันที่ผ่านมา

      Thanks, I appreciate it!

  • @hackvlix
    @hackvlix ปีที่แล้ว +2

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

  • @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!

  • @jophycui2454
    @jophycui2454 ชั่วโมงที่ผ่านมา

    Thanks for the video, I have got it running.

  • @harrylai5233
    @harrylai5233 3 หลายเดือนก่อน

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

  • @anilkumarsahoo909
    @anilkumarsahoo909 2 ปีที่แล้ว +1

    Thanks mam, my first deployment done seamlessly.

  • @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

  • @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?

  • @staslis1924
    @staslis1924 9 หลายเดือนก่อน

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

  • @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.

  • @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.

  • @lexxluey
    @lexxluey ปีที่แล้ว

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

  • @ProjectXH
    @ProjectXH หลายเดือนก่อน

    Marvelous explanation!

  • @javalex561
    @javalex561 9 หลายเดือนก่อน

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

  • @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.

  • @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.🥰

  • @chessinaglimpse9899
    @chessinaglimpse9899 5 วันที่ผ่านมา

    This was so helpful, thank you so much

  • @matheusandrade1059
    @matheusandrade1059 7 หลายเดือนก่อน

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

  • @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/)

  • @amiralikhan
    @amiralikhan 10 หลายเดือนก่อน

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

  • @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 🙏

  • @etsw
    @etsw ปีที่แล้ว

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

  • @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`?

  • @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!!!!!

  • @alaminbijoy1027
    @alaminbijoy1027 3 ปีที่แล้ว +1

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

  • @lucaslourencoschimidt8480
    @lucaslourencoschimidt8480 10 หลายเดือนก่อน

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

  • @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

  • @philippbraun9306
    @philippbraun9306 3 ปีที่แล้ว

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

  • @FullRGB
    @FullRGB 3 ปีที่แล้ว

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

  • @manho2965
    @manho2965 2 ปีที่แล้ว +3

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

  • @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 😅

  • @maiadasilvapereira4633
    @maiadasilvapereira4633 8 หลายเดือนก่อน

    Thank you very much It is very useful Tutorial

  • @subinkv6849
    @subinkv6849 7 หลายเดือนก่อน

    Easy to understand great presentation.

  • @nickheyer
    @nickheyer 2 ปีที่แล้ว +1

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

  • @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.

  • @Randomguy-zv3tv
    @Randomguy-zv3tv ปีที่แล้ว

    explanation is so clear, thank you

  • @EchoVids2u
    @EchoVids2u 2 ปีที่แล้ว

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

  • @lofmaan
    @lofmaan ปีที่แล้ว

    really nice tutorial, looking forward to more videos

  • @hasithaeranga5589
    @hasithaeranga5589 ปีที่แล้ว

    very clear and onto the point

  • @agpark-yg8vs
    @agpark-yg8vs 4 หลายเดือนก่อน

    thank you!!! you literally save my life lol

  • @lolcraft2067
    @lolcraft2067 3 ปีที่แล้ว

    Thank you, the best tutorial on the topic

  • @MrRynRules
    @MrRynRules ปีที่แล้ว

    Thank you so much, it was so well explained!

  • @slog7590
    @slog7590 2 ปีที่แล้ว

    Thankyou so much , for such wonderful explaination.

  • @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

  • @vitali1959
    @vitali1959 2 หลายเดือนก่อน

    Thanks, great video!

  • @nickolasmaslow7041
    @nickolasmaslow7041 ปีที่แล้ว

    thank you very much, this is the best explanation

  • @middleclass3782
    @middleclass3782 3 ปีที่แล้ว

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

  • @SUMITKUMAR-hl4fp
    @SUMITKUMAR-hl4fp 3 ปีที่แล้ว

    Love from India. Keep going ❤️

  • @fergusfariuson3910
    @fergusfariuson3910 3 ปีที่แล้ว

    Super. Thanks from Uzbekistan

  • @fahadKhanDev
    @fahadKhanDev 3 ปีที่แล้ว

    Great tutorial I love your teaching method

  • @imhan7026
    @imhan7026 8 หลายเดือนก่อน

    wow, perfect tutorial, thank you so much

  • @kuglatec
    @kuglatec ปีที่แล้ว

    This is just perfect! Thanks alot!

  • @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.

  • @JoaoCarlosCvel
    @JoaoCarlosCvel 11 หลายเดือนก่อน

    perfect explained, thank you!

  • @avahsieh4645
    @avahsieh4645 3 ปีที่แล้ว

    Clearly explained. Thank you.

  • @finn9233
    @finn9233 2 ปีที่แล้ว

    this finally worked thank you.

  • @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 ?

  • @rajeshs3771
    @rajeshs3771 3 ปีที่แล้ว

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

  • @dr99tm23
    @dr99tm23 3 ปีที่แล้ว

    Clear tutorial ,Keep going ,thanks 👍

  • @robertarustamyan5168
    @robertarustamyan5168 4 หลายเดือนก่อน

    Thank you for explanation

  • @arashsayareh7728
    @arashsayareh7728 3 ปีที่แล้ว

    Very very obvious and useful. Thanks!

  • @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.

  • @liorbm1
    @liorbm1 3 ปีที่แล้ว

    This is really great !
    Thank You !

  • @AliMohammed-zn5ih
    @AliMohammed-zn5ih 3 ปีที่แล้ว

    very simple and useful 😸 💚💚
    Keep going ☺️

  • @anandumdharan6283
    @anandumdharan6283 2 ปีที่แล้ว

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

  • @farhadkabir1321
    @farhadkabir1321 3 ปีที่แล้ว

    very simple and informative

  • @angeldelgado6193
    @angeldelgado6193 3 ปีที่แล้ว

    Thanks from Venezuela!!

  • @louisdevitry8240
    @louisdevitry8240 3 ปีที่แล้ว

    Thanks! Great explanation 🔥

  • @AllthingsFoodieTX
    @AllthingsFoodieTX 2 ปีที่แล้ว

    Good job 👍 simple and effective

  • @multimediaceron2742
    @multimediaceron2742 11 หลายเดือนก่อน

    Great tutorial, thanks a lot

  • @alaminbijoy1027
    @alaminbijoy1027 3 ปีที่แล้ว

    wow! straight to the point

  • @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!

  • @mahrezbenhamad4445
    @mahrezbenhamad4445 3 ปีที่แล้ว +3

    Thanks, keep going

  • @arcsin4083
    @arcsin4083 6 หลายเดือนก่อน

    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.

  • @ferdiansahgg
    @ferdiansahgg 2 หลายเดือนก่อน

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

  • @hongjeon9671
    @hongjeon9671 3 ปีที่แล้ว

    Very clear. Thx for the vid

  • @frankstuart6032
    @frankstuart6032 3 ปีที่แล้ว +1

    ModuleNotFoundError: No module named 'myproject.wsgi'
    This is the error im getting when im running gunicorn -c conf/gunicorn_config.py myproject.wsgi

    • @alexdeathway
      @alexdeathway 3 ปีที่แล้ว +1

      Have you specified the correct path (PYTHONPATH) for your project in Gunicorn_config.py.

    • @frankstuart6032
      @frankstuart6032 3 ปีที่แล้ว

      @@alexdeathway yes

    • @alexdeathway
      @alexdeathway 3 ปีที่แล้ว +1

      @@frankstuart6032 remember you have to put path only till the dir which contain wsgi.py file. So that you can use myproject.wsgi in command
      for example if your wsgi file is located in:
      home/username/myproject/myproject/wsgi.py
      your pythonpath should be:
      PYTHONPATH="/home/username/myproject"

    • @frankstuart6032
      @frankstuart6032 3 ปีที่แล้ว

      @@alexdeathway thankyou i got it🙏🏽

  • @feluve
    @feluve ปีที่แล้ว +1

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

  • @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 };
    }

    • @username_6948
      @username_6948 ปีที่แล้ว

      DUDE THANKS it worked for me aswell

  • @itzmeraj6253
    @itzmeraj6253 3 ปีที่แล้ว

    You are simply 👏👏😁 awesome

  • @hamoudguicheniti3949
    @hamoudguicheniti3949 3 ปีที่แล้ว

    Thank you so much, great job!

  • @yannickpezeu3419
    @yannickpezeu3419 3 ปีที่แล้ว

    crystal clear. Thank you !