我已经将 lighttp 配置为通过 ubuntu 上的 fastcgi 启动和服务 django。当我只启用了一个站点时(通过 ubuntu 的类似 apache 的 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",
)
当我启用第二个站点时,一切都是相同的,除了现在有第二个链接指向10-example.conf
启用 conf 的(稍作修改的)副本。发生这种情况时,我的网站会因 django-served 错误而失败:
Page not found (404)
Request Method: GET
Request URL: http://example.com/django.fcgi/[the url I requested]
我不确定为什么启用另一个站点会破坏现有设置。我相信基于主机的语法应该隔离对该特定主机的任何更改,但似乎并非如此。