deploying django application on Apache using mod_wsgi

独自空忆成欢 提交于 2019-12-24 16:42:57

问题


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?


回答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.




回答2:


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


来源:https://stackoverflow.com/questions/14181812/deploying-django-application-on-apache-using-mod-wsgi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!