Apache2 突然只给出内部 500 错误

Apache2 突然只给出内部 500 错误

我有一个 Ubuntu Server 10.04 的 VM 实例,运行带有 mod_wsgi 的 django。它运行良好,然后在执行 /etc/init.d/apache2 重新加载和 /etc/init.d/apache2 重新启动后,我只收到内部 500 错误。我检查了日志,当我访问服务器时,它什么也没有输出。但是,当服务器重新启动时,我得到了以下内容,据我所知,这与我的问题无关。

编辑:刚刚意识到我有一个自定义日志文件,不在通常的位置。以下是实际日志文件一直以来捕获的内容:

  [Mon Jul 19 05:40:10 2010] [info] [client 192.168.1.152] mod_wsgi (pid=1693, process='', application='192.168.1.153|'): Loading WSGI script '/srv/www/mysite.com/application/django.wsgi'.
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152] mod_wsgi (pid=1693): Exception occurred processing WSGI script '/srv/www/mysite.com/application/django.wsgi'.
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152] Traceback (most recent call last):
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     response = self.get_response(request)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 142, in get_response
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return self.handle_uncaught_exception(request, resolver, exc_info)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 166, in handle_uncaught_exception
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return debug.technical_500_response(request, *exc_info)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/views/debug.py", line 58, in technical_500_response
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     html = reporter.get_traceback_html()
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/views/debug.py", line 137, in get_traceback_html
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return t.render(c)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py", line 173, in render
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return self._render(context)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py", line 167, in _render
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return self.nodelist.render(context)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py", line 796, in render
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     bits.append(self.render_node(node, context))
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py", line 72, in render_node
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     result = node.render(context)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/template/debug.py", line 89, in render
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     output = self.filter_expression.resolve(context)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/template/__init__.py", line 579, in resolve
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     new_obj = func(obj, *arg_vals)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/template/defaultfilters.py", line 693, in date
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return format(value, arg)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/dateformat.py", line 281, in format
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return df.format(format_string)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/dateformat.py", line 30, in format
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     pieces.append(force_unicode(getattr(self, piece)()))
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/dateformat.py", line 187, in r
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return self.format('D, j M Y H:i:s O')
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/dateformat.py", line 30, in format
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     pieces.append(force_unicode(getattr(self, piece)()))
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/encoding.py", line 66, in force_unicode
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     s = unicode(s)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 206, in __unicode_cast
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return self.__func(*self.__args, **self.__kw)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 55, in ugettext
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return real_ugettext(message)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 55, in _curried
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 36, in delayed_loader
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return getattr(trans, real_name)(*args, **kwargs)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 276, in ugettext
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     return do_translate(message, 'ugettext')
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 266, in do_translate
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     _default = translation(settings.LANGUAGE_CODE)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 176, in translation
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     default_translation = _fetch(settings.LANGUAGE_CODE)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 159, in _fetch
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     app = import_module(appname)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]   File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152]     __import__(name)
[Mon Jul 19 07:40:11 2010] [error] [client 192.168.1.152] TemplateSyntaxError: Caught 

ImportError while rendering: No module named mysite.website

[Mon Jul 19 07:40:11 2010] [debug] mod_deflate.c(615): [client 192.168.1.152] Zlib: Compressed 620 to 383 : URL /admin

答案1

我唯一更改的是 django 文件。我确实更改了 urls.py 文件

mod_wsgi (pid=1693): 处理 WSGI 脚本'/srv/www/mysite.com/application/django.wsgi 时发生异常

返回并查看您更改的内容,然后确认上面错误日志中显示的错误。这应该很明显。您的更改导致了错误。尝试恢复您修改的 django 文件...例如 urls.py

答案2

在您的 /etc/apache2/apache2.conf 文件中,您可以打开日志记录并可能捕获错误。您应该找到如下部分:

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

将其更改为此并尝试重新启动服务器:

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel debug

相关内容