1

I've got some problems with deploying Django application on Apache HTTP server with mod_wsgi. I've added information to httpd.conf (WSGIScriptAlias) which indicate file wsgi.py with test content:

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]

and when I run it everything seems to be OK, bacause I can see 'Hello world!'. But when I change file wsgi.py to this:

import os
import sys

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

I've got:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

wsgi.py file is in the same directory as settings.py file... (and all my app is in the subdirectory: mydomain/public_html/hc/hc/hc/settings.py - hc is the name of my app)

What can be wrong? What should I do, to make my app work? how to find out which thing causes error?

jrola
  • 298
  • 7
  • 21
  • 1
    Plus you should post the error from the Apache log (probably /var/httpd/error.log). – Daniel Roseman Jan 06 '13 at 11:59
  • Definitely an Apache config issue. It may be a permissions problem. Also, take a look at [this similar issue](http://stackoverflow.com/questions/3584713/importerror-no-module-named-django-core-handlers-wsgi-in-install-django-mod-wsg). – Ian Atkin Jan 06 '13 at 12:05
  • post your apache configuration file – karthikr Jan 06 '13 at 14:16
  • anyone from my previous topic didn't help me, so i can't match anything – jrola Jan 06 '13 at 16:28
  • i've got no permission to access apache configuration file - i've got django hosting and i can only add alias to httpd.conf (which is added by admin) - so configuration of apache is probably good, any other ideas? – jrola Jan 06 '13 at 16:33

2 Answers2

1
sys.path.append('path_to_python_dir')
sys.path.append('path_to_project')

add these lines to your wsgi.py file .

Issues in settings.py also causes 500 error.

Anthon
  • 69,918
  • 32
  • 186
  • 246
Anoop
  • 2,748
  • 4
  • 18
  • 27
0

i've solve my problem on my own added this help me (after imports):

sys.path.append('path_to_project')
sys.path.append('path_to_wsgi_py_file')
jrola
  • 298
  • 7
  • 21