Django MOD_PYTHON 错误

发布于 2024-07-14 22:14:20 字数 1563 浏览 10 评论 0原文

我已经让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无言温柔 2024-07-21 22:14:20

我只能猜测你的问题可能是什么,但这里有两个标准检查:

  1. 从几个不同的工作目录在 shell 中导入 modpython
  2. 更改用户(如果除了 root 设置之外还有其他用户)并重复步骤 1

如果 #2 看起来更多麻烦大于其价值,然后尝试非常非常仔细检查 modpython 路径上每个文件夹的权限,以确保“其他”在整个过程的每个阶段都具有读取访问权限。 如果你已经将 django 移动到你的主目录中(就像我曾经做过的那样......不知道为什么,但得到了同样的错误),这将是问题所在。 您要么需要将其移回到 apache 可以读取的目录中,要么需要为其他目录添加读取权限。

I can only guess what your problem might be, but here are two standard checks:

  1. Import modpython in shell, from a couple different working directories
  2. Change users (if you have any besides root set up) and repeat step 1

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.

动听の歌 2024-07-21 22:14:20

就我而言, 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文