好的,所以我在尝试使用FastCGI在lighttpd上运行Django时遇到了问题。我按照here的说明进行了操作,但仍无法使其工作,并且不确定问题是什么。
与runserver
一起运行时,django项目可以正常工作。
所以,我开始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",
)
使用此配置(或者如果我将“/ django”替换为fastcgi.server
和url.rewrite-once
中的“.fcgi”或“/ django.fcgi”,我始终< / em>在尝试访问/
时获取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。
这是在Amazon EC2上,运行Fedora Core 8.我甚至从源代码安装了最新的lighttpd版本,而不是分发版中的旧版本。
答案 0 :(得分:1)
与上面的评论一样,“check-local”需要设置为“disabled”。