I'm about to deploy a mediumsized site powered by Django. I have a dedicated Ubuntu Server.

I'm really confused over which serversoftware to use. So i thought to myself: why not ask stackoverflow.

What i'm looking for is:

  • Easy to set up
  • Fast and easy on resources
  • Can serve mediafiles
  • Able to serve multiple djangosites on same server
  • I would rather not install PHP or anything else that sucks resources, and for which I have no use for.

I have heard of mod_wsgi and mod_python on Apache, nginx and lighty. Which are the pros and cons of these and have i missed someone?

@Barry: Somehow i feel like Apache is to bloated for me. What about the alternatives?

@BrianLy: Ok I'll check out mod_wsgi some more. But why do i need Apache if i serve static files with lighty? I have also managed to serve the django app itself with lighty. Is that bad in anyway? Sorry for beeing so stupid :-)

UPDATE: What about lighty and nginx - which are the uses-cases when these are the perfect choice?

Accepted Answer

Since i was looking for some more in-depth answers, i decided to research the issue myself in some more depth. Please let me know if i've misunderstood something.

General recommendation is to use a separate webserver for handling media. Separate means a webserver which is not running django. This server can be for instance:

  • Lighttpd (Lighty)
  • Nginx (EngineX
  • Or some other light-weight server

Then, for django, you can go down different paths. You can either:

  • Serve Django via Apache and:

    • mod_python

      This is the stable and recommended/well documented way. Cons: uses a lot of memory.

    • mod_wsgi

      From what i understand, mod_wsgi is a newer alternative. It appears to be faster and easier on resources.

    • mod_fastcgi

      When using FastCGI you are delegating the serving of Django to another process. Since mod_python includes a python interpreter in every request it uses a lot of memory. This is a way to bypass that problem. Also there is some security concerns.

      What you do is that you start your django fastcgi server in a separate process and then configures apache via rewrites to call this process when needed.

Or you can:

  • Serve django without using Apache but with another server that supports FastCGI natively:

    (The documentation mentions that you can do this if you don't have any Apache specific needs. I guess the reason must be to save memory.)

    • Lighttpd

    This is the server that runs Youtube. It seems fast and easy to use, however i've seen reports on memoryleaks.

    • nginx

    I've seen benchmarks claiming that this server is even faster than lighttpd. It's mostly documented in russian though.

Another thing, du to limitations in Python your server should be running in forked mode, note threaded.

So this is my current research, But i want more opinions and experiences.

Written by jamting
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki