Django MOD_PYTHON 错误
我已经让 django 使用 mod_python 运行了一段时间,但今天我收到以下错误
MOD_PYTHON ERROR
ProcessId: 4551
Interpreter: 'thatch'
ServerName: 'thatch'
DocumentRoot: '/var/www/thatch'
URI: '/'
Location: '/'
Directory: None
Filename: '/var/www/thatch/'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1202, in _process_target
module = import_module(module_name, path=path)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 304, in import_module
return __import__(module_name, {}, {}, ['*'])
ImportError: No module named django.core.handlers.modpython
这是我的虚拟主机配置
<VirtualHost *:80>
ServerName thatch
DocumentRoot /var/www/thatch
<Location "/">
SetHandler python-program
PythonPath "['/var/www/thatch'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE thatch.settings
PythonOption django.root /var/www/thatch
PythonDebug On
</Location>
<Location "/media">
SetHandler None
</Location>
<LocationMatch "\.(jpg|gif|png|css|js)$">
SetHandler None
</LocationMatch>
</VirtualHost>
你知道为什么会发生这种情况吗?
I have had django running with mod_python for awhile now but today I get the following error
MOD_PYTHON ERROR
ProcessId: 4551
Interpreter: 'thatch'
ServerName: 'thatch'
DocumentRoot: '/var/www/thatch'
URI: '/'
Location: '/'
Directory: None
Filename: '/var/www/thatch/'
PathInfo: ''
Phase: 'PythonHandler'
Handler: 'django.core.handlers.modpython'
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1202, in _process_target
module = import_module(module_name, path=path)
File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 304, in import_module
return __import__(module_name, {}, {}, ['*'])
ImportError: No module named django.core.handlers.modpython
This is my virtual host configuration
<VirtualHost *:80>
ServerName thatch
DocumentRoot /var/www/thatch
<Location "/">
SetHandler python-program
PythonPath "['/var/www/thatch'] + sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE thatch.settings
PythonOption django.root /var/www/thatch
PythonDebug On
</Location>
<Location "/media">
SetHandler None
</Location>
<LocationMatch "\.(jpg|gif|png|css|js)$">
SetHandler None
</LocationMatch>
</VirtualHost>
Any ideas why this is happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只能猜测你的问题可能是什么,但这里有两个标准检查:
如果 #2 看起来更多麻烦大于其价值,然后尝试非常非常仔细检查 modpython 路径上每个文件夹的权限,以确保“其他”在整个过程的每个阶段都具有读取访问权限。 如果你已经将 django 移动到你的主目录中(就像我曾经做过的那样......不知道为什么,但得到了同样的错误),这将是问题所在。 您要么需要将其移回到 apache 可以读取的目录中,要么需要为其他目录添加读取权限。
I can only guess what your problem might be, but here are two standard checks:
If #2 looks like more trouble than it's worth, then try very, very carefully examining permissions for each folder along the path to modpython to make sure that "other" has read access at every stage along the way. If you've moved django into your home directory (like I did once...not sure why, but got the same error) that'll be the problem. You either need to move it back into a directory where apache can read or you need to add read permission for other.
就我而言, pytonpath 和访问权限都可以。
重新编译python后这个错误消失了。
配置:
Gentoo
Django 1.1
阿帕奇:
www-servers/apache-2.2.15 USE="doc ssl suexec 线程-debug -ldap (-selinux) -static" APACHE2_MODULES="alias auth_basic authn_alias authn_anon authn_default authn_file authz_default authz_host authz_owner autoindex 缓存 dav dav_fs dav_lock deflate dir disk_cache env 过期 ext_过滤器file_cache 过滤器标头包括信息 log_config logio mem_cache mime mime_magic 协商重写 setenvif 拼写状态 unique_id userdir usertrack vhost_alias -actions -asis -auth_digest -authn_dbd -authn_dbm -authz_dbm -authz_groupfile -authz_user -cern_meta -charset_lite -dbd -dumpio -ident -imagemap -log_forensic -代理-proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -substitute -version" APACHE2_MPMS="worker -event -itk -peruser -prefork"
Python 2.6.4
In my case pytonpath and access rights was ok.
This error disappeared after recompilation python.
Configuration:
Gentoo
Django 1.1
Apache:
www-servers/apache-2.2.15 USE="doc ssl suexec threads -debug -ldap (-selinux) -static" APACHE2_MODULES="alias auth_basic authn_alias authn_anon authn_default authn_file authz_default authz_host authz_owner autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias -actions -asis -auth_digest -authn_dbd -authn_dbm -authz_dbm -authz_groupfile -authz_user -cern_meta -charset_lite -dbd -dumpio -ident -imagemap -log_forensic -proxy -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -substitute -version" APACHE2_MPMS="worker -event -itk -peruser -prefork"
Python 2.6.4