但是,我对django和lighttpd很新,对FastCGI有很粗略的想法。我的“server.document-root”下有一个名为“myproject”的django项目。
当我尝试浏览以下网址时:
http://192.168.1.198:8093/myproject.fcgi
我收到导入错误说:
Request Method: GET
Request URL: http://192.168.1.198:8093/myproject.fcgi
Django Version: 1.2.4
Exception Type: ImportError
Exception Value:
No module named myproject.urls
Exception Location: /usr/lib/python2.6/site-packages/django/utils/importlib.py in
import_module, line 35
Python Executable: /usr/bin/python2.6
Python Version: 2.6.2
用于配置FastCGI的“lighttpd.conf”文件的片段是:
$HTTP["host"] =~ "192\.168\.1\.198" {
fastcgi.server = (
".fcgi" => (
"192\.168\.1\.198" => (
"bin-path" => "/satellite_app/webservers/lighttpd/var/www/htdocs/myproject/myproject.fcgi",
"socket" => "/tmp/myproject.sock",
"check-local" => "disable",
"min-procs" => 2,
"max-procs" => 4,
)
),
)
alias.url = (
"/media" => "/usr/lib/python2.6/site-packages/django/contrib/admin/media/",
)
url.rewrite-once = (
"^(/media.*)$" => "$1",
"^/favicon\.ico$" => "/media/favicon.ico",
"^(/.*)$" => "/myproject$1",
## "^(/.*)$" => "/myproject.fcgi$1",
)
}
我无法确定为什么会收到“ImportError”。我在任何地方都错过了进口声明吗?如果有,请告诉我到底在哪里?
提前致谢。
答案 0 :(得分:0)
好的,既然我自己想出了问题,我正在回答自己的问题,希望能帮助像我这样的其他新手......
DJANGO_MODULE_SETTINGS
的值存在问题。
将其设为:
os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
解决了我的ImportError ...: - )