如何使用WSGI在Apache2中部署Django时修复错误(wsgi.py,第284行)

时间:2011-12-20 03:43:23

标签: python django apache2 mod-wsgi wsgi

我在使用mod_wsgi在apache2中部署django时遇到此错误消息,我无法修复它:

tail -f /var/log/apache2/error.log
[Tue Dec 20 04:15:45 2011] [info] mod_wsgi (pid=3959): Adding '/usr/local/lib/python2.7/site-packages/' to path.
[Tue Dec 20 04:15:45 2011] [info] [client 80.226.1.7] mod_wsgi (pid=3959, process='', application='digitalchaot.de|/djangu'): Loading WSGI script '/home/webapps/digitalchaot/apache.wsgi'.
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] mod_wsgi (pid=3959): Exception occurred processing WSGI script '/home/webapps/digitalchaot/apache.wsgi'.
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] Traceback (most recent call last):
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7]   File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 284, in __call__
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7]     start_response(status, response_headers)
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] TypeError: expected byte string object for status, value of type str found
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] File does not exist: /htdocs
[Tue Dec 20 04:20:11 2011] [error] [client 207.46.13.206] File does not exist: /htdocs
[Tue Dec 20 04:20:57 2011] [error] [client 207.46.13.206] File does not exist: /htdocs

我正在使用带有Django 1.3.1的Python 2.7.2和当前的mod_wsgi运行Debian。由于之前的错误,我自己编译了python,django和wsgi。有没有人提示错误可能是什么?

1 个答案:

答案 0 :(得分:2)

对于Python错误,看起来你的mod_wsgi是针对Python 3.1而不是Python 2.7编译的。您需要确保安装的mod_wsgi是针对Python 2.7编译的。

线索是错误消息抱怨状态是字节字符串而不是文本字符串。这只能在带有mod_wsgi的Python 3.X中发生。

完成本文档中的检查:

http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation