0

環境:

wsgiを使用したvirtalenv apache-2.2のaws
django-1.4.5のubuntu

ジャンゴ設定.py:

TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), '..', 'templates').replace('\\', '/'),)

apache2 エラー ログ:

[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] mod_wsgi (pid=1794): Exception occurred processing WSGI script '/home/ubuntu/Sites/tushanwan/tushanwan/wsgi.py'.
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] Traceback (most recent call last):
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102]   File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102]   File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/core/handlers/base.py", line 179, in get_response
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102]   File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102]   File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102]   File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/views/defaults.py", line 32, in server_error
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102]   File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/template/loader.py", line 145, in get_template
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102]   File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] TemplateDoesNotExist: 500.html

私は 1 日を費やし、aws ubuntu インスタンスでこの問題を解決するために多くの方法を試しましたが、どれもうまくいきませんでした。同じ方法で django アプリケーションをローカルの ubuntu サーバーにデプロイしましたが、うまくいきました。

4

1 に答える 1

3

から: https://docs.djangoproject.com/en/dev/topics/http/views/#the-500-server-error-view

DEBUG が (設定モジュールで) True に設定されている場合、500 ビューは使用されず、代わりにデバッグ情報と共にトレースバックが表示されます。

したがって、開発サーバーではすべてが正常に機能する可能性がありますが、運用サーバーで (テンプレート フォルダーのルートに) 500.html がない場合、フレームワークでエラーが発生します。

補足: Django 1.4.x では 404.html および 500.html ファイルが必要です。Django 1.5.x では、このパッチのおかげで、500.html および 404.html ファイルは厳密には必要なくなりました。

于 2013-03-11T15:38:25.120 に答える