3
我剛剛爲django設置了lightc的fastcgi,但我在處理url時獲取了fcgi文件路徑,例如, 404錯誤http://myserver.myhost.com/myproject.fcgi。它需要路由到/而不是/myproject.fcgi。使用lighttpd,django和fastcgi時的URL問題
萊蒂的conf:
$HTTP["host"] =~ "myproject\.myhost\.com" {
fastcgi.server = (
".fcgi" => (
"localhost" => (
"bin-path" => "/var/www/myproject/myproject.fcgi",
"socket" => "/tmp/myproject.sock",
"check-local" => "disable",
"min-procs" => 2,
"max-procs" => 4,
)
),
)
alias.url = (
"/media" => "/usr/local/lib/python1.6/dist-packages/Django-1.2.1-py2.6.egg/django/contrib/admin/media/",
)
url.rewrite-once = (
"^(/media.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/.*)$" => "/myproject.fcgi$1",
)
}
myproject.fcgi:
#!/usr/bin/python2.6
import sys, os
# Add a custom Python path.
sys.path.insert(0, "..")
# Switch to the directory of your project. (Optional.)
os.chdir("/var/www/myproject")
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(["method=threaded", "daemonize=false"])
感謝你的這一點,一直在關於這個問題,我的腦子有點痛苦! – glenc 2010-09-03 19:56:25
Np,django的完整教程在這裏:http://appdelegateinc.com/blog/2010/08/08/django-via-fastcgi-on-lighttpd/ – 2010-09-03 20:23:05