1

好的,所以我在尝试使用 FastCGI 在 lighttpd 上运行 Django 时遇到问题。我已按照此处的说明进行操作,但仍然无法使其正常工作,并且不确定问题出在哪里。

django 项目在使用runserver.

所以,我开始 django:

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

lighttpd fastcgi 配置如下所示:

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

fastcgi.server使用此配置(或者如果我在and中将“/django”替换为“.fcgi”或“/django.fcgi” url.rewrite-once)我在尝试访问时总是/得到 404 (文件/static工作正常)。在error.log中,看起来服务器从未尝试过 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/ 

如果我将 fastcgi 条目设置为“/”,并省略该url.rewrite-once部分,django 进程确实会被调用,但看起来传递的 URI 始终是“/”,因此对“/static”中内容的请求返回的 HTML根视图。

这是在运行 Fedora Core 8 的 Amazon EC2 上。我什至从源代码安装了最新的 lighttpd 版本,而不是分发中的旧版本。

4

1 回答 1

1

如上面的评论,“check-local”需要设置为“disabled”。

于 2012-02-02T19:55:57.197 回答