So I have two website running on my droplet( Nginx + Gunicorn). What If I want to install different django version on each project? I created virtualvenv in each projects directories and installed succesfully different Django versions. But now what?
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.
Using the Django One-Click app as an example of a fairly typical Django setup, Gunicorn is used to run the app while Nginx sits in front of it as a reverse proxy. Nginx can also be used to route requests between different domains by creating separate “server blocks” for each app.
Clipping somethings out for brevity, on the one-click the Nginx configuration looks like:
This takes the Django app that is available locally at port 9000 and makes it available publicly at port 80. So to run another app, we’d need to server it on a separate port and allow Nginx to route it accordingly. It might look something like:
The
server_name
directive is important here. Any requests made tosubproject.my-domain.com
will be directed to port 7000 while requests to my-domain.com will go to 9000.The port that the app is running on local is determined by Gunicorn. On the one-click Guinicon is started and stopped with an Upstart script installed to
/etc/init/gunicorn.conf
As you are using a virtualenv, you’ll need to adapt that script to use the Guinicon from inside the virtualenv. You can make a copy of that script updating the port and file paths for your second app.