Linux serverlinux web serverNETWORK ADMINISTRATIONS

How to Deploy Django on Nginx with uWSGI (full tutorial)

Learn how to deploy a Django website on Nginx with uWSGI as a web server gate interface. In this complete tutorial, we will use Ubuntu 20.04 and the latest version of Django and uWSGI. Nginx will communicate requests to the WSGI via a UNIX socket. Additionally, we will create a system service to launch the website at boot (and keep the service running).

Need a server to deploy your Django site? Try Linode 👉 https://ttt.do/LinodeDjangoDeploy ($100 free Linode credits when you use my affiliate link)
Code snippets and more at https://tonyteaches.tech/django-nginx-uwsgi-tutorial/

Check out my vlog channel @TonyFlorida

#django #uwsgi #nginx #ubuntu

source

by Tony Teaches Tech

linux web server

20 thoughts on “How to Deploy Django on Nginx with uWSGI (full tutorial)

  • Thanks for the upload. Excellent tutorial 👍 are you using virtual box for local development?

  • Thank you man, still the best video… with the best explanation… really appreciated

  • I add a lfew to your comment.

    The United States is the world's number one drug country. Drugs are commonly sold in middle and high schools. Drug addicts can become homeless in their 20s and 30s.

    In Democrat-controlled blue states, the police will not only treat the theft of goods worth less than $950 as a misdemeanor. but Police budgets and staffing have, also been cut, It resultis in so many thefts from stores and supermarkets that stores and supermarkets are closing one after another.

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

  • you basically just now created the Django project, how come the localhost got linked with your domain?

  • 23:57 i got an error, Restarting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited with error code. I wen t step by step but here is the first time You mentioning /etc/init.d/nginx

  • What should be content and permission of .sock file mine is empty ? error i am getting permission denied when while connecting to upstream client

  • In case you get a 502 bad gateway: this could be because the www-data user doesn't have permission to read/write in the microdomains directory.
    the following worked for me:

    $ sudo groupadd webusers

    $ sudo usermod -aG webusers www-data

    $ sudo usermod -aG webusers another-user

    $ sudo chown -R :webusers /path/to/directory

    $ sudo chmod -R 770 /path/to/directory

    $ sudo chmod 771 /path/to/directory

    I hope this helps you

  • Fantastic and detailed. This worked for me where others did not. Thank you

  • at 23:00 min ( the google gif part) i'm getting 403 Forbidden

    nginx/1.18.0 (Ubuntu), anyone know how to solve it? i'm using a vps/droplet from digital ocean with ssh

  • Hi Tony, I was wondering if this is compatible with Dreamhost or where Dreamhost comes into play in this stack? Thanks!

  • Have anyone faced 403 at the end of 5th step instead of gif?
    How to fix it?

  • Apache2 libapache2-mod-wsgi-py3 is away lot easier

Comments are closed.