Welcome! Log In Create A New Profile

Advanced

Configure Nginx to run Django apps

Posted by JAM 
JAM
Configure Nginx to run Django apps
February 12, 2011 01:17AM
I would like to configure Nginx to run Django applications.

I've seen on several websites, and comments that say I can use Nginx + Gunicorn, Nginx + uWSGI, Nginx + python-flup and the like, but also and seen bechmark where Nginx works best with uWSGI.

My question is, what is best for running Django using nginx as web server? and where to find manuals/tutorials/ examples to configure?

Do you know any updated guide that explains how to configure Nginx + Django uWSGI to run applications?

Greetings and thanks in advance
Re: Configure Nginx to run Django apps
February 12, 2011 08:55AM
This is one of the latest howto:

http://django.docshub.org/tutorials/4/deploying-your-django-applications-with-nginx-and-uwsgi

It covers all the areas (startup files included).

uWSGI is bigger (hundreds of configuration options) than most of the WSGI server out there and this can
be a PITA for newcomers, but if you follow this howto you should not have particular problems.

Roberto
JAM
Re: Configure Nginx to run Django apps
February 12, 2011 08:01PM
thanks friend, works perfect

I only see this error: "ImportError at / No module named appdjango.views. "

To fix this, i rename the calls to views.py simply views. note that this call is in the urls.py file and appear as appdjango.views by default

Although it works properly, I do not like this solution because any new file or call to modules me or Django make should then be renamed in this way to work correctly with Nginx and uWSGI. Do you know a better way?

Greetings and thanks in advance

PD: sorry for my bad English
Re: Configure Nginx to run Django apps
February 13, 2011 02:40AM
If i understand correctly you reference a particular view in urls.py with

'appdjango.views'

and this does not work.

If you simply use

'views'

it works.

This is a simple pythonpath problem.
Add to your configuration file (or commandline as used in the howto) a <pythonpath>/--pythonpath directive set to the directory that contains
'appdjango'.

So if you have this layout:


/foo
/foo/app
/foo/app/views.py

your pythonpath would be

<pythonpath>/foo</pythonpath>
<pythonpath>/foo/app</pythonpath>

Or for following the howto, add

--pythonpath /home

This will reach the same result as app like Pinax use.



Edited 1 time(s). Last edit at 02/13/2011 02:40AM by roberto.
JAM
Re: Configure Nginx to run Django apps
February 13, 2011 01:55PM
Yes, I just realized that in the - PYTHONPATH must reference the full path to the folder where the Django project (appdjango) and not the folder itself ("... python / django / "and not "...python/django/appdjango"). Is working properly the Django app

Greetings and thanks.



Edited 1 time(s). Last edit at 02/13/2011 01:56PM by JAM.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 185
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready