![在 Ubuntu+Django 上设置 Apache 时出现 500 内部服务器错误](https://linux22.com/image/597938/%E5%9C%A8%20Ubuntu%2BDjango%20%E4%B8%8A%E8%AE%BE%E7%BD%AE%20Apache%20%E6%97%B6%E5%87%BA%E7%8E%B0%20500%20%E5%86%85%E9%83%A8%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%94%99%E8%AF%AF.png)
我尝试在 ubuntu 9.04 上使用 Apache,但出现同样的错误:内部服务器错误,服务器遇到内部错误或配置错误,无法完成您的请求。
请联系服务器管理员 webmaster@localhost 并告知他们错误发生的时间以及可能导致错误的任何操作。
有关此错误的更多信息可以在服务器错误日志中找到。
我的 apache/error.log 是:
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] ServerName: 'sapint2'
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] DocumentRoot: '/etc/apache2/htdocs' [Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] URI: '/'
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] Location: '/'
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] Directory: None
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] Filename: '/etc/apache2/htdocs'
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] PathInfo: '/'
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] Traceback (most recent call last):
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch\n default=default_handler, arg=req, silent=hlist.silent)
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1229, in _process_target\n result = _execute_target(config, req, object, arg)
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/lib/python2.7/dist-packages/mod_python/importer.py", line 1128, in _execute_target\n result = object(arg)
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/modpython.py", line 180, in handler\n return ModPythonHandler()(req)
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/modpython.py", line 142, in call\n self.load_middleware()
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware\n mod = import_module(mw_module)
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module\n import(name)
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/contrib/sessions/middleware.py", line 4, in \n from django.utils.cache import patch_vary_headers
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/utils/cache.py", line 25, in \n from django.core.cache import get_cache
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/cache/init.py", line 187, in \n cache = get_cache(DEFAULT_CACHE_ALIAS)
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/cache/init.py", line 179, in get_cache\n cache = backend_cls(location, params)
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File "/usr/local/lib/python2.7/dist-packages/django/core/cache/backends/memcached.py", line 139, in init\n "Memcached cache backend requires either the 'memcache' or 'cmemcache' library"
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] InvalidCacheBackendError: Memcached cache backend requires either the 'memcache' or 'cmemcache' library [Sat Oct 06 09:51:30 2012] [notice] caught SIGTERM, shutting down [Sat Oct 06 09:51:31 2012] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Sat Oct 06 09:51:31 2012] [notice] mod_python: using mutex_directory /tmp
[Sat Oct 06 09:51:31 2012] [notice] Apache/2.2.17 (Ubuntu) PHP/5.3.5-1ubuntu7.11 with Suhosin-Patch mod_python/3.3.1 Python/2.7.1+ mod_wsgi/3.3 configured -- resuming normal operations
我需要一些帮助谢谢
答案1
您使用的 Django 版本是什么?您是否尝试根据收到的日志消息采取行动并安装其中一个建议的 memcache 库?它就在那里:
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] File
"/usr/local/lib/python2.7/dist-packages/django/core/cache/backends/memcached.py",
line 139, in init\n "Memcached cache backend requires either the
'memcache' or 'cmemcache' library"
[Sat Oct 06 09:32:04 2012] [error] [client 10.0.64.10] InvalidCacheBackendError:
Memcached cache backend requires either the
'memcache' or 'cmemcache' library
这就是您的 apache 返回 500 错误的原因。