2009-06-17 37 views
2

我已將lighttp配置爲通過Ubuntu上的fastcgi啓動並提供django服務。當我只啓用了一個站點時(通過Ubuntu的類似Apache的conf-available,啓用conf的機制),一切都運行良好。當我啓用第二個站點時,我的url重寫似乎停止正常工作,儘管fcgi進程已啓動並提供數據。下面是我的配置:Ubuntu中的Lighttpd + FCGI中的Django - 當我啓用第二個站點時重寫停止工作

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", 
) 

當我啓用第二個站點,一切都是相同的,只是現在有一個第二個鏈接的10-example.conf(稍微修改)的副本在conf-enabled中。發生這種情況時,我的網站會失敗,此Django的服務錯誤:

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

我不知道爲什麼讓其他網站應該打破現有的設置。我相信基於主機的語法應該隔離對特定主機的任何更改,但似乎並非如此。

回答

2

如果有人在將來看到這個問題,我相信答案是它在1.4.20或更高版本中修復,而服務器運行的是v1.4.19,因爲這是Ubuntu的存儲庫。

2

您是否已將FORCE_SCRIPT_NAME設置爲「」settings.py?

FORCE_SCRIPT_NAME="" 
+0

是的,那沒有效果。 – 2009-07-10 17:54:59

相關問題