在Apache使用mod_wsgi的部署Django应用程序 [英] deploying django application on Apache using mod_wsgi

查看:125
本文介绍了在Apache使用mod_wsgi的部署Django应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题与mod_wsgi的的Apache HTTP服务器上部署Django应用程序。我已经添加信息的httpd.conf(WSGIScriptAlias​​)这表明与测试内容文件wsgi.py:

 高清应用(ENVIRON,start_response):
    状态=200 OK
    输出=世界,你好!    response_headers = [('内容类型','text / plain的'),
                        (内容长度,STR(LEN(输出)))]
    start_response(状态,response_headers)    返回[输出]

和当我运行它的一切似乎是好了,bacause我可以看到世界,你好!。但是,当我更改文件wsgi.py这样:

 导入OS
进口SYSos.environ ['DJANGO_SETTINGS_MODULE'] ='mysite.settings'进口django.core.handlers.wsgi
应用= django.core.handlers.wsgi.WSGIHandler()

我有:

 内部服务器错误服务器遇到内部错误或配置错误,无法完成您的请求。

wsgi.py文件在同一目录settings.py文件...(和我的所有应用程序是在子目录:MYDOMAIN /的public_html / HC / HC / HC / settings.py - HC是的我的名字应用程序)

什么可能是错误的?我应该怎么做,使我的应用程序的工作?如何找出哪些事情会导致错误?


解决方案

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

这些行添加到您的wsgi.py文件。

在settings.py问题也导致500错误。

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?

解决方案

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.

这篇关于在Apache使用mod_wsgi的部署Django应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆