jrola
jrola

Reputation: 416

deploying django application on Apache using mod_wsgi

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?

Upvotes: 1

Views: 3174

Answers (2)

Anoop
Anoop

Reputation: 2798

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.

Upvotes: 1

jrola
jrola

Reputation: 416

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')

Upvotes: 0

Related Questions