使用lighttpd、django和fastcgi时的URL问题
我刚刚为 django 设置了 lighty 的 fastcgi,但是在处理 url 时我得到了 fcgi 文件路径,例如 http://myserver.myhost.com/myproject.fcgi。它需要路由到 / 而不是 /myproject.fcgi。
Lightyconf:
$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"])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我再次回答我自己的问题。将其放入settings.py
Once again I answer my own question. Put this into settings.py