简体   繁体   中英

Issue in deployment zc.buildout with apache

I am facing some issues with deploying my buildout project (Django) in Apache using mod_wsgi.

My folder structure:

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/
        ....

Appache config file:

<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}

The apache error log I got is:

[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

I give prmission(777) to bin folder.

To test wsgi work, I changed my django.wsgi as follows and I revert it back to old one.

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]

It gave me the result Hello World!.

Can you help me to find out the issues?

You're getting a TemplateDoesNotExist error which means you're missing a '500.html' template (see the docs ).

I would suggest setting DEBUG to True in your settings.py file (see docs ). That will cause django to use the built in debugging template (instead of the missing '500.html'). The debugging template will give you more information to work with...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM