1

OK, so I'm having issues trying to run Django on lighttpd with FastCGI. I've followed the instructions here, but still can't get it to work, and am not sure what the problem is.

The django project does work when running with runserver.

So, I start django:

python manage.py runfcgi socket=/var/run/django/django.sock pidfile=/var/run/django/django-fcgi.pid

The lighttpd fastcgi configuration looks like this:

server.document-root        = "/srv/www/lighttpd/"

fastcgi.server = (
"/django" => (
        (
            "socket" => "/var/run/django/django.sock",
            "check-local" => "enable",
        )
    ),
)

alias.url = (
    "/static" => "/srv/www/lighttpd/static",
)

url.rewrite-once = (
    "^(/static.*)$" => "$1",
    "^(/.*)$" => "/django$1",
)

With this configuration (or if I replace "/django" with, say, ".fcgi" or "/django.fcgi" in the fastcgi.server and url.rewrite-once) I always get a 404 when trying to access / (files in /static work fine). In error.log, it looks like the server isn't ever trying FastCGI:

2011-02-24 16:18:00: (response.c.300) -- splitting Request-URI 
2011-02-24 16:18:00: (response.c.301) Request-URI  :  / 
2011-02-24 16:18:00: (response.c.302) URI-scheme   :  http 
2011-02-24 16:18:00: (response.c.303) URI-authority:  XXX.amazonaws.com 
2011-02-24 16:18:00: (response.c.304) URI-path     :  / 
2011-02-24 16:18:00: (response.c.305) URI-query    :   
2011-02-24 16:18:00: (response.c.300) -- splitting Request-URI 
2011-02-24 16:18:00: (response.c.301) Request-URI  :  /d.fcgi/ 
2011-02-24 16:18:00: (response.c.302) URI-scheme   :  http 
2011-02-24 16:18:00: (response.c.303) URI-authority:  XXX.amazonaws.com 
2011-02-24 16:18:00: (response.c.304) URI-path     :  /d.fcgi/ 
2011-02-24 16:18:00: (response.c.305) URI-query    :   
2011-02-24 16:18:00: (response.c.349) -- sanatising URI 
2011-02-24 16:18:00: (response.c.350) URI-path     :  /d.fcgi/ 
2011-02-24 16:18:00: (mod_access.c.135) -- mod_access_uri_handler called 
2011-02-24 16:18:00: (response.c.470) -- before doc_root 
2011-02-24 16:18:00: (response.c.471) Doc-Root     : /srv/www/lighttpd/ 
2011-02-24 16:18:00: (response.c.472) Rel-Path     : /d.fcgi/ 
2011-02-24 16:18:00: (response.c.473) Path         :  
2011-02-24 16:18:00: (response.c.521) -- after doc_root 
2011-02-24 16:18:00: (response.c.522) Doc-Root     : /srv/www/lighttpd/ 
2011-02-24 16:18:00: (response.c.523) Rel-Path     : /d.fcgi/ 
2011-02-24 16:18:00: (response.c.524) Path         : /srv/www/lighttpd/d.fcgi/ 
2011-02-24 16:18:00: (response.c.541) -- logical -> physical 
2011-02-24 16:18:00: (response.c.542) Doc-Root     : /srv/www/lighttpd/ 
2011-02-24 16:18:00: (response.c.543) Rel-Path     : /d.fcgi/ 
2011-02-24 16:18:00: (response.c.544) Path         : /srv/www/lighttpd/d.fcgi/ 
2011-02-24 16:18:00: (response.c.561) -- handling physical path 
2011-02-24 16:18:00: (response.c.562) Path         : /srv/www/lighttpd/d.fcgi/ 
2011-02-24 16:18:00: (response.c.618) -- file not found 
2011-02-24 16:18:00: (response.c.619) Path         : /srv/www/lighttpd/d.fcgi/ 

If I set the fastcgi entry to "/", and omit the url.rewrite-once section, the django process does get called, but it looks like the URI passed is always "/", so requests for stuff in "/static" return the HTML of the root view.

This is on Amazon EC2, running Fedora Core 8. I've even installed the latest lighttpd version from source, instead of the old one in the distribution.

Casey Marshall
  • 934
  • 7
  • 13
  • Ugh. OK. The problem was "check-local" needs to be "disabled". The old version of lighttpd I was trying kept rejecting the "check-local" config, and would never work. Excuse the noise. – Casey Marshall Feb 24 '11 at 21:48
  • I'm glad you got it working! You should answer your own question and accept it as answered (when it lets you:P) so others running into this problem can easily see the solution. – Yuji 'Tomita' Tomita Feb 25 '11 at 00:13

1 Answers1

1

As in the comment above, "check-local" needs to be set to "disabled".

Casey Marshall
  • 934
  • 7
  • 13