V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
adamwen
V2EX  ›  Django

关于django+apache2+wsgi的deploy问题

  •  
  •   adamwen · 2012-08-30 00:48:20 +08:00 · 3710 次点击
    这是一个创建于 4229 天前的主题,其中的信息可能已经有所发展或是发生改变。
    目前文件结构如下
    --proj
    |-----proj (自动建立的)
    |-----qcsa (自己建的app)
    |-----manage.py
    |-----apache2 (用来存放django.wsgi)

    整个目录存放在/var/www/下
    用manage runserver运行完全没有问题
    但是用apache2+wsgi的时候访问总是报500错误

    整个项目的配置文件当用runserver运行成功后 只去掉了debug信息
    根据网上的一些资料 目前配置如下
    但总是在访问的时候报出500错误 求解决方法

    机器使用ubuntu11.04
    经测试wsgi模块正常
    求解决方法

    这是apache2的default的内容
    <VirtualHost *:80>
    ServerName 127.0.0.1
    DocumentRoot /var/www/qcsa
    <Directory /var/www/qcsa>
    Order allow,deny
    Allow from all
    </Directory>
    WSGIDaemonProcess qcsa.djangoserver processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup qcsa.djangoserver
    WSGIScriptAlias / /var/www/qcsa/apache/django.wsgi
    </VirtualHost>



    这是django.wsgi的内容
    import os
    import sys

    path = '/var/www'
    if path not in sys.path:
    sys.path.insert(0, '/var/www')

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

    import django.core.handlers.wsgi

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



    报错信息如下:
    Internal Server Error

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

    Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.
    3 条回复    1970-01-01 08:00:00 +08:00
    kojp
        1
    kojp  
       2012-08-30 09:19:25 +08:00
    没玩过wsgi.
    但是建议参考这条 in the server error log.
    看日志~~
    everyx
        2
    everyx  
       2012-08-31 01:21:51 +08:00
    你的django应用是那个qcsa的话,猜测你
    os.environ
    ['DJANGO_SETTINGS_MODULE'] =
    'proj.settings'
    的 proj.settings要改成qcsa.settings
    wangst321
        3
    wangst321  
       2013-01-28 23:59:02 +08:00
    建议先看看error.log,500的错误,可能是环境变量的问题。
    "WSGIPythonPath /var/www/qcsa/",增加这个配置,类似的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3959 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 05:12 · PVG 13:12 · LAX 22:12 · JFK 01:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.