[英]apache virtual host to work with 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
您需要PythonPath中的項目文件夾和測試文件夾,因為您的項目使用的路徑中沒有“測試”:
PythonPath "['/home/projects/', '/home/projects/testing/'] + sys.path"
該路徑對我來說看起來還可以,我只是仔細檢查了sys.path
中的項目是否可以使用斜杠。
我建議這是一個文件權限問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.