views:

64

answers:

1

I just set up fastcgi with lighty for django, but I'm getting the fcgi file path when it processes the url, e.g. 404 error at http://myserver.myhost.com/myproject.fcgi. It needs to route to / instead of /myproject.fcgi.

Lighty conf:

$HTTP["host"] =~ "myproject\.myhost\.com" {
        fastcgi.server = (
         ".fcgi" => (
           "localhost" => (
             "bin-path" => "/var/www/myproject/myproject.fcgi",
             "socket" => "/tmp/myproject.sock",
             "check-local" => "disable",
             "min-procs" => 2,
             "max-procs" => 4,
          )
        ),
)

        alias.url = (
            "/media" => "/usr/local/lib/python1.6/dist-packages/Django-1.2.1-py2.6.egg/django/contrib/admin/media/",
        )

        url.rewrite-once = (
        "^(/media.*)$" => "$1",
        "^/favicon\.ico$" => "/media/favicon.ico",
        "^(/.*)$" => "/myproject.fcgi$1",
    )
}

myproject.fcgi:

#!/usr/bin/python2.6
import sys, os

# Add a custom Python path.
sys.path.insert(0, "..")

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

os.environ['DJANGO_SETTINGS_MODULE'] = "settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(["method=threaded", "daemonize=false"])
+1  A: 

Once again I answer my own question. Put this into settings.py

FORCE_SCRIPT_NAME = ""
Matt Williamson
Thanks for this, been wracking my brain about this one for a bit!
glenc
Np, full tutorial for django here: http://appdelegateinc.com/blog/2010/08/08/django-via-fastcgi-on-lighttpd/
Matt Williamson