Django,lighttpd,FastCGI—无法让它工作
好的,所以我在尝试使用FastCGI在lighttpd上运行Django时遇到了问题。我按照这里的说明进行操作,但仍然无法使其工作,我不确定问题是什么。
使用
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",
)
使用这种配置(或者如果我在fastcgi.server
和url.rewrite-once
中用“.fcgi”或“/django.fcgi”替换“/ django”)我在尝试访问/
时总是得到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版本,而不是分发版中的旧版本。
没有找到相关结果
已邀请:
1 个回复
土投