关于django+apache2+wsgi的deploy问题

2012-08-30 00:48:20 +08:00
 adamwen
目前文件结构如下
--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.
3749 次点击
所在节点    Django
3 条回复
kojp
2012-08-30 09:19:25 +08:00
没玩过wsgi.
但是建议参考这条 in the server error log.
看日志~~
everyx
2012-08-31 01:21:51 +08:00
你的django应用是那个qcsa的话,猜测你
os.environ
['DJANGO_SETTINGS_MODULE'] =
'proj.settings'
的 proj.settings要改成qcsa.settings
wangst321
2013-01-28 23:59:02 +08:00
建议先看看error.log,500的错误,可能是环境变量的问题。
"WSGIPythonPath /var/www/qcsa/",增加这个配置,类似的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/46461

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX