apache 虚拟主机与 django 一起使用
我的项目位于:/home/projects/testing 下,我将其添加到 Centos 计算机上的 /etc/httpd/conf/httpd.conf 文件的底部,但这不起作用,
<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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在 PythonPath 中同时包含项目文件夹和测试文件夹,因为您的项目使用的路径中不含“testing”:
You want both, the projects folder and the testing folder in your PythonPath, because your project uses paths without the "testing" in it:
该路径对我来说看起来不错,我刚刚仔细检查了 sys.path 中的项目是否可以使用尾部斜杠。
我建议这是一个文件权限问题:
The path looks okay to me, I've just double checked that items in
sys.path
work with trailing slashes.I'd suggest that this is a file permissions issue: