Minimilisticaly: Deploying Django using Nginx on Ubuntu 12.10

371 views
Skip to first unread message

djangobie

unread,
Dec 27, 2012, 2:26:12 AM12/27/12
to django...@googlegroups.com
Hi all, 
I am trying to deploy my Django project using Nginx, tried various tutorials. All of them are filled bunch of dependencies and requirements. Here I am looking forward to a simple (in sure way minimilistic), procedure to do so i.e. deploying my Django project (mysite1) and (mysite2) with apps (myapp1) and (myapp2).

P.S, I am not looking for some solution stating use of 'virtualenv' or in combination with other servers i.e. 'Apache' or 'Gunicorn' etc.
It would be top, if you can explain the settings + config using (mysite1) with (myapp1). 

Thanks

donarb

unread,
Dec 27, 2012, 12:08:15 PM12/27/12
to django...@googlegroups.com
You could try this tutorial https://gist.github.com/3094281.

But you're going to have to run some sort of extra server, be it Apache, Gunicorn, or uWSGI. Nginx does not run any apps, that is why it is so fast, it takes requests and either returns file system objects or routes requests to other processes. The tutorial above uses Nginx and uWSGI to handle the Django app. It starts out showing you how to use it with virtualenv, then shows how to run the app without virtualenv.

If you're running more than one app on a site, you might want to learn how to use virtualenv. This can save lots of time and headaches in the future when you decide you want to upgrade one of your apps to a newer version of python or some other module. Otherwise, upgrading anything on the system globally will break all your apps that depend on a specific version of software. And virtualenv is not that mysterious, all it really does is put all of your application's dependencies into a directory and modify any system paths and environment variables to point to that directory. It makes it easy to test and deploy your application to any server.

Nikolas Stevenson-Molnar

unread,
Dec 27, 2012, 1:28:33 PM12/27/12
to django...@googlegroups.com
These two documents should get you what you need:

1) Django deployment via FastCGI: https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ (scroll down a bit to the 'runfcgi' manage.py command).
2) Nginx FastCGI example configuration: http://wiki.nginx.org/FcgiExample

That shouldn't have any dependencies past nginx and Django. However, I would encourage you to reconsider using Gunicorn or similar. It's super easy to get running and makes the nginx configuration much easier, as you only need to set up an http proxy, and don't need to wrestle with all the fastcgi_param business.

_Nik
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/na_ZM3qY5IoJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Nikolas Stevenson-Molnar

unread,
Dec 27, 2012, 1:32:20 PM12/27/12
to django...@googlegroups.com
Here's a Django-specific doc for FastCGI configuration with Nginx: http://wiki.nginx.org/DjangoFastCGI

Though again: Gunicorn will make your life easier. There's a reason that most of the tutorials you've found use these extra components.

_Nik

djangobie

unread,
Dec 28, 2012, 12:35:54 AM12/28/12
to django...@googlegroups.com
I appreciate your response. I have good idea of 'virtualenv', an indespinsble tool.
What I am basically trying to do here is, to have a strong grasp over how Nginx behave, once I'll have it 'll definitely move forward to next step (using it in combination).
-I have installed Nginx (configured), and now I want to test my Django project (mysite1 with myapp1) at my localhost root (var/www).

Thanks
Reply all
Reply to author
Forward
0 new messages