Lightbupd中的Django + Ubuntu上的FCGI - 当我启用第二个站点时,重写停止工作

时间:2009-06-17 20:20:59

标签: django ubuntu lighttpd fastcgi

我已经配置了lighttp来启动并通过ubuntu上的fastcgi提供django。当我只启用一个站点时(通过ubuntu的apache-like conf-available,conf-enabled机制),一切都运行得很漂亮。当我启用第二个站点时,我的URL重写似乎停止正常工作,尽管fcgi进程已启动并提供数据。这是我的配置:

conf-available/10-example.conf

$HTTP["host"] == "example.com" {
    var.virt_name = "example"
    include "includes/incl-fastcgi.conf"
}

includes/incl-fastcgi.conf

global {
    server.modules += ("mod_rewrite",
                   "mod_fastcgi")
}

var.site_folder = "/" + virt_name
var.site_root = server_root + site_folder
var.socket = server_root + "/.handles/" + virt_name + ".socket"
server.document-root = site_root

fastcgi.server = (
    "/django.fcgi" => (
        "main" => (
            "socket" => socket,
            "bin-path" => "/etc/lighttpd/scripts/fcgi.sh",
            "bin-environment" => ( "VIRT" => virt_name, ),
            "check-local" => "disable",
            "min-procs" => 1,
            "max-procs" => 1,
            "allow-x-send-file" => "enable",
        ),
    ),
)

alias.url = (
    "/media/admin" => "/usr/share/python-support/python-django/django/contrib/admin/media", #why the hell does it live here?
)

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

当我启用第二个站点时,除了现在在conf-enabled中有10-example.conf的(略微修改的)副本的第二个链接之外,一切都是相同的。发生这种情况时,我的网站因django服务错误而失败:

Page not found (404)
Request Method:     GET
Request URL:    http://example.com/django.fcgi/[the url I requested]

我不确定为什么启用其他网站会破坏现有设置。我相信基于主机的语法应该隔离对该特定主机的任何更改,但似乎并非如此。

2 个答案:

答案 0 :(得分:2)

如果将来有人看到这个问题,我相信答案是它已经在版本1.4.20或更高版本中修复,并且服务器正在运行v1.4.19,因为那是Ubuntu的存储库。

答案 1 :(得分:2)

您是否在settings.py?

中将FORCE_SCRIPT_NAME设置为“”
FORCE_SCRIPT_NAME=""
相关问题