So you wrote a fancy little Django app and want to run it on a lighttpd webserver? There's plenty of documentation on this topic online, including official Django documentation.
Problem is, most of these sources do not mention how to use virtualenv, but the cool kids don't install their packages into the global site-packages directory. So I put some scripts together for your enjoyment.
I assume that you've put your django app somewhere convenient, and that you have a virtualenv containing its packages (including django itself).
You want to set up this file so it adds the virtualenv's
site-packages path to its site-packages:
site.addsitedir('path/to/mysite-env/lib/python2.6/site-packages'). Note that you need to point directly to the site-packages dir inside the virtualenv, not only the main virtualenv dir. For obvious reasons, this line needs to come before the django-provided
from django... import, because you can't import django files if Python doesn't know where they are.
The lighttpd setup will result in
mysite.fcgi showing up in all your URLs, unless you set
FORCE_SCRIPT_NAME correctly. If your django app is supposed to live right at the root of your domain, set this to the empty string, for example.
This is an initscript (for Debian, but you can modify it to work with most distros, I presume). Copy it to
/etc/init.d, adjust the settings on top (and possibly other places, depending on your setup), then start the Django fastcgi servers. Note that you need to have the
flup package installed in your virtualenv.
Set up your lighttpd vhost pretty much like the Django documentation suggests. Match up the host and port with the settings from your init script. By using
mod_alias for the media and admin media paths, you'll have lighttpd serve them instead of passing them on to Django as well.
That's it! You've deployed your first Django application on lighttpd. If you have any questions or suggestions, feel free to comment here or fork my code.