我的项目位于:/ home/projects/testing,我将它添加到Centos机器上的/etc/httpd/conf/httpd.conf文件的buttom中,但那是不工作,apache虚拟主机与django一起工作
<Location "/testing/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE testing.settings
PythonOption django.root /testing
PythonDebug On
PythonPath "['/home/projects/'] + sys.path"
</Location>
但请求http://localhost/testing/jobs例如当,我得到:
Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) ............. File "/usr/lib/python2.4/site-packages/Django-1.1.1-py2.4.egg/django/conf/__init__.py", line 75, in __init__ raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) ImportError: Could not import settings 'testing.settings' (Is it on sys.path? Does it have syntax errors?): No module named testing.settings
根据指示更新了PythonPath,并直接在项目内的设置文件上进行设置。仍然没有运气。 – khelll 2010-03-30 13:01:11
@reko_t:回溯说“导入错误”,“没有名为testing.settings的模块”。假设文件'/ home/projects/testing/__ init __。py'和'/ home/projects/testing/settings.py'存在,路径上的'/ home/projects'就足够了。这就是为什么我会说它更可能是mod_python无法读取这些文件,而不是找不到它们。 – MattH 2010-03-30 13:10:32
如果'/ home/projects/testing/__ init __。py'不存在,那么导入'testing.settings'将失败。我建议让你的Python路径为@reko_t建议,但是使用:'SetEnv DJANGO_SETTINGS_MODULE settings'。这应该工作天气'__init __。py'存在与否。 – 2010-03-30 16:47:49