固定
我的设置:
apache + mod_python 使用CentOS的VPS django 1.2.5
我已将文件上传到/ mysite
并设置httpd.conf如下:
< VirtualHost *:80 >
DocumentRoot /var/www/html/domain
ServerName www.domain.com
ServerAlias domain.com
#django...
<Location "/mysite">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite
PythonDebug On
PythonPath "['/var/www/html/domain/mysite'] + sys.path"
</Location>
CustomLog logs/access_log cplus
< /VirtualHost >
我收到此错误:
Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
File "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
result = object(req)
File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 228, in handler
return ModPythonHandler()(req)
File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 191, in __call__
self.load_middleware()
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 33, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "/usr/lib/python2.4/site-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 40, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.4/site-packages/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 'mysite.settings' (Is it on sys.path? Does it have syntax errors?): No module named mysite.settings
答案 0 :(得分:1)
您正在为www.domain.com/mysite
定义处理程序您是否尝试过访问该网址?
如果您希望www.domain.com显示您的mysite应用
<Location "/">
...
# remove django.root /mysite
</Location>
修改强>
对于您的第二个问题:mysite.settings
不在您的python路径中。将'/ var / www / html / domain'添加到PythonPath列表中,可能只使用settings
,因为DJANGO_SETTINGS_MODULE也可以解决问题。
希望有所帮助!