前段时间用django作了个小项目,交付测试时必须在windows上部署。遇到过如下问题:
1,bnu.settings等找不到
原因是没有加路径
PythonPath "['D:/workspace/NewSite','D:/workspace/NewSite/bnu','D:/server/python24/Lib/site-packages/django']
2,拒绝访问
原因是没有设置访问权限
<Directory "D:/workspace/NewSite/bnu/media/">
Order Deny,Allow
Allow from all
</Directory>
3,在测试server里面正常,在mod_python里面异常
原因:以前用了一些print语句,mod_python不能正常处理,去掉调试语句
def navtree(request):
lang = request.session.get('django_language', 'zh')
navbar = get_navtree(request.user, lang)
print request.path #这罗要去掉
我现在的apache配置文件最好加上了:
LoadModule python_module modules/mod_python.so
<Location "/">
SetHandler python-program
PythonPath "['D:/workspace/NewSite','D:/workspace/NewSite/bnu','D:/server/python24/Lib/site-packages/django'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE bnu.settings_apache
PythonDebug On
</Location>
Alias /media D:/workspace/NewSite/bnu/media
<Location "/media/">
SetHandler None
</Location>
<LocationMatch "\.(jpg|gif|png|css|js)$">
SetHandler None
</LocationMatch>
<Directory "D:/workspace/NewSite/bnu/media/">
Order Deny,Allow
Allow from all
</Directory>
测试时仍然建议设置DEBUG = True