Question

How to host Django Application using gunicorn & nginx in Production

Posted July 12, 2021 91 views
NginxDjangoPython FrameworksUbuntu 20.04

Hello
I have 2 Django Application that I want to run in a same server and I have 2 domain name. Please tell me how to host this 2 Django Application in same server this is the domain and file locations for my application.

  1. First Application —>
    Domain –> harshblog.tech
    file location for my project –> /home/harsh/harshblog
    file location for my python environment –> /home/harsh/harshblog/env
    file location for my wsgi.py –> /home/harsh/harshblog/harshbloging/wsgi.py

  2. Second Application –>
    Domain –> kingofmemes.xyz
    file location for my project –> /home/harsh/harshmemes
    file location for my python environment –> /home/harsh/harshmemes/env
    file location for my wsgi.py –> /home/harsh/harshmemes/memes/wsgi.py

If you need more information related to this 2 Application please tell me and please help me.
This 2 application is running on apache2 in different server. So, I want to run this 2 applications in nginx in a same server.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hello,

This should be achievable with Nginx server blocks as per this tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

Once you have your two Nginx server blocks, you can configure them as per the instruction in the Configure Nginx to Proxy Pass to Gunicorn step in this tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

Hope that this helps!
Regards,
Bobby

by Justin Ellingwood
Django is a powerful web framework that can help you get your Python application or website off the ground. Django includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure and powerful web server...