0

mod_wsgi を使用してビルドアウト プロジェクト (Django) を Apache にデプロイする際にいくつかの問題に直面しています。

私のフォルダ構造:

t/
  bootstrap.py
  setup.py
  bin/
     buildout
     django
     django.wsgi
     .....
  eggs/
       raven-3.1.13-py2.7.egg
       ..........
  parts
  project
  develop-eggs
  src/
     some files
  myapp/

    files
    settings.py
    apicontainer/
        ....

アパッチ構成ファイル:

<VirtualHost *:80>
        DocumentRoot /home/.../tests/website
         ServerName testapp.com
        <Directory /home/.../tests/website>
            Order allow,deny
            Allow from all
        </Directory>

        Alias /website/ /home/.../tests/website/

        WSGIDaemonProcess testapp.com processes=2 threads=15 display-name=%{GROUP}
        WSGIProcessGroup testapp.com
        # ........ pointing to buildout's django.wsgi ..........
        WSGIScriptAlias / /home/.../tests/t/bin/django.wsgi
        WSGIPassAuthorization On

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn    
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

./bin/django.wsgi

#!/usr/bin/python


import sys
sys.path[0:0] = [
  '/home/.../tests/t/eggs/raven-3.1.13-py2.7.egg',
  '/usr/lib/python2.7/dist-packages',
   ...........
   ...........

  '/home/.../tests/t/eggs/djangorecipe-1.5-py2.7.egg',
  '/home/.../tests/t/eggs/zc.recipe.egg-2.0.0a3-py2.7.egg',
  '/home/.../tests/t',
  ]

import djangorecipe.wsgi

application = djangorecipe.wsgi.main('testproj.settings', logfile='')

buildout.cfg

[buildout]
parts = python
        django

develop = .
eggs = raven
       .....
       .....

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

[django]
recipe = djangorecipe
wsgi = true
project = testproj
settings = settings
eggs = ${buildout:eggs}

私が得たApacheエラーログは次のとおりです。

[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1] mod_wsgi (pid=9772): Exception occurred processing WSGI script '/home/.../tests/t/bin/django.wsgi'.
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 272, in __call__
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]     response = self.get_response(request)
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 153, in get_response
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 218, in handle_uncaught_exception
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]     return callback(request, **param_dict)
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py", line 93, in _wrapped_view
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]     response = view_func(request, *args, **kwargs)
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/dist-packages/django/views/defaults.py", line 30, in server_error
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]     t = loader.get_template(template_name) # You need to create a 500.html template.
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/dist-packages/django/template/loader.py", line 157, in get_template
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]     template, origin = find_template(template_name)
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]   File "/usr/lib/python2.7/dist-packages/django/template/loader.py", line 138, in find_template
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1]     raise TemplateDoesNotExist(name)
[Thu Feb 21 06:19:09 2013] [error] [client 127.0.0.1] TemplateDoesNotExist: 500.html

binフォルダに権限(777)を与えます。

wsgi の動作をテストするために、django.wsgi を次のように変更し、古いものに戻しました。

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

結果は Hello World! でした。

問題を見つけるのを手伝ってもらえますか?

4

1 に答える 1

0

「500.html」テンプレートがないことを意味する TemplateDoesNotExist エラーが発生しています (ドキュメントを参照してください)。

DEBUGファイルに を設定することTrueをお勧めしsettings.pyます ( docsを参照)。これにより、django は ('500.html' が欠落している代わりに) 組み込みのデバッグ テンプレートを使用するようになります。デバッグ テンプレートは、作業するための詳細情報を提供します...

于 2013-02-22T10:20:12.723 に答える