Electronics & Programming


Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Problem trying to configure Django with FastCGI and Lighttpd [RSS Feed]

#1 June 21, 2010 10:57:56

Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Problem trying to configure Django with FastCGI and Lighttpd

I know this thread is rather old but for those who come across this
trying to identify their issues here's how I got things working for me
on Ubuntu 10.04.

The major issue to the above poster's issue was with permissions. The
www-data user that's running the lighttpd process needs to be able to
execute the .fcgi script. Once that is fixed then running is easy.
Your user that's running your server process maybe named something
else. I use 'htop' to see running processes (or you can use 'top'
since it's likely to already be installed on your distro) and who owns
those processes.

Here's my .fcgi script:
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/var/www/sites/example/mysite")

# Switch to the directory of your project. (Optional.)
# os.chdir("/home/user/myproject")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ = "mysite.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="prefork", daemonize="false")

And my relevant lighttpd.conf setup:
fastcgi.server = (
"/example.fcgi" => (
"main" => (
# Use host / port instead of socket for TCP fastcgi
"bin-path" => "/var/www/sites/example/mysite.fcgi",
"host" => "",
"port" => 2001,
#"socket" => "/var/www/sites/example/example.sock",
"check-local" => "disable",
"max-procs" => 2,
"idle-timeout" => 20,

I was running with a .sock file setup where I ran ./manage.py
runfcgi ... but I didn't want to have a process that had to trigger on
server startup and would rather just let the server own the starting
so that's why I went the route of using a .fcgi script and setting up
the .conf to start the processes.

I do have one issue though and maybe someone can help answer why this
is. Even though I have "max-procs" => 2, I count 12 processes that
are running ... is this because I'm not specifying a child process
count or something? Also, on my rackspace cloud server I'm only
getting about 30 requests/sec on static or dynamic content using AB
from my local desktop and hitting my server...is there something I
should be looking into to find out why this is the case? I'm very new
to the who sysadmin thing and having to wear this hat for now.

Thanks in advance for any pointers/help - I was able to get about 350+
requests/sec using Apache2 and mod_wsgi on a VM player Ubuntu
appliance (using Ubuntu 10.04 just like on the cloud)...so unless my
cable connection to the outside world is slowing things up for me I
don't see why lighttpd and/or my server environment is running so

You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.


  • Root
  • » Django
  • » Problem trying to configure Django with FastCGI and Lighttpd [RSS Feed]

Board footer

Moderator control

Enjoy the 23rd of March

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support