nginx is a reverse proxy and needs to connect to a server that contains django. This guide is for using [https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ fastcgi], but you could instead use [http://bartek.im/blog/2009/04/06/setting-up-nginx-django.html apache+mod_wsgi], [http://senko.net/en/django-nginx-gunicorn/ gunicorn], [https://www.google.com/search?q=nginx+uwsgi+django uwsgi], or [http://www.rkblog.rk.edu.pl/w/p/django-nginx/#3 SCGI+Cherokee] ---- This assumes you are using ubuntu 10.04 or later. You'll need nginx and flup installed. {{{ sudo aptitude install nginx python-flup }}} In your django project, start up fastcgi. See the [https://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/ fastcgi docs] for more info. {{{ python ./manage.py runfcgi host=127.0.0.1 port=8080 }}} Next, we need to create a configuration file in `/etc/nginx/sites-available/sample_project.conf` and symlink it to `/etc/nginx/sites-enabled/sample_project.conf`: {{{ sudo touch /etc/nginx/sites-available/sample_project.conf sudo ln -s /etc/nginx/sites-available/sample_project.conf /etc/nginx/sites-enabled/sample_project.conf }}} Here is what a minimal conf file would look like: {{{ server { listen 80; server_name myhostname.com; access_log /var/log/nginx/sample_project.access.log; error_log /var/log/nginx/sample_project.error.log; # https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-production location /static/ { # STATIC_URL alias /home/www/myhostname.com/static/; # STATIC_ROOT expires 30d; } location /media/ { # MEDIA_URL alias /home/www/myhostname/static/; # MEDIA_ROOT expires 30d; } location / { include fastcgi_params; fastcgi_pass 127.0.0.1:8080; } } }}} Now, reload nginx. {{{ sudo /etc/init.d/nginx reload }}} You may use a unix socket instead of a port number like so: `fastcgi_pass unix:/home/www/myhostname/fastcgi.sock` You'll probably want to keep your fastcgi process running using [http://blog.bashton.com/2011/using-django-fastcgi-with-upstart/ upstart], [https://code.djangoproject.com/wiki/InitdScriptForLinux init.d], or [http://just-another.net/byteflowdjango-supervisord-nginx-win supervisor] See also: - [http://serverfault.com/a/370573/84192 serverfault question on django+nginx] - [http://wiki.nginx.org/DjangoFastCGI nginx wiki page on django+FastCGI]