0

我正在尝试使用 Apache 2.22 和 WSGI 3.3 部署 pinax0.9a2。我正在使用 pinax 提供的 wsgi.py。但我在 apache 错误日志中收到 500 错误和以下错误:

[Sun Aug 19 03:31:55.895469 2012] [core:error] [pid 9045:tid 140546171721472] [client 107.192.29.14:62182] End of script output before headers: wsgi.py

[Sun Aug 19 03:31:56.424077 2012] [core:notice] [pid 7789:tid 140546404792064] AH00052: child pid 9225 exit signal Aborted (6)

[Sun Aug 19 03:31:56.742536 2012] [core:error] [pid 9044:tid 140546196899584] [client 107.192.29.14:62183] Invalid status line from script 'wsgi.py': Status
ng.co: Objects/stringobject.c:115: PyString_FromString: Assertion `str != ((void *)0)' failed.

[Sun Aug 19 03:31:56.966168 2012] [core:error] [pid 9044:tid 140546196899584] [client 107.192.29.14:62183] End of script output before headers: wsgi.py

[Sun Aug 19 03:31:57.426321 2012] [core:notice] [pid 7789:tid 140546404792064] AH00052: child pid 9243 exit signal Aborted (6)

Apache httpd.conf:

<VirtualHost *:80>

    DocumentRoot /usr/local/apache2/mysite

    WSGIDaemonProcess mysite.com python-path=/usr/local/apache2/mysite-env/lib/python2.6/site-packages processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup mysite.com

    WSGIScriptAlias / /usr/local/apache2/mysite/wsgi.py

    <Directory "/usr/local/apache2/mysite">
    Require all granted
    </Directory>

</VirtualHost>

wsgi.py:

from django.core.handlers.wsgi import WSGIHandler

import pinax.env


# setup the environment for Django and Pinax
pinax.env.setup_environ(__file__)


# set application for WSGI processing
application = WSGIHandler()
4

1 回答 1

0

如果我不得不猜测,那是因为您的 sys.path 不包括 pinax。我的大多数 wsgi 脚本都是从设置系统路径开始的,以便在 mod_wsgi 中运行的 python 可以找到 pinax 和 django。

import sys
sys.path = [
"/home/username/Python/project/project/apps",
"/home/username/Python/project/project",
"/home/username/Python/project/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg",
"/home/username/Python/project/src/django-mailer",
"/home/username/Python/project/src/django-axes",
"/home/username/Python/project/src/django-notification",
"/home/username/Python/project/src/pinax",
"/home/username/Python/project/src/django-email-confirmation",
"/home/username/Python/project/src/idios",
"/home/username/Python/project/src/pil-withg4-dev/PIL",
"/home/username/Python/project/src/django-deployment",
"/home/username/Python/project/lib/python2.7",
"/home/username/Python/project/lib/python2.7/plat-linux2",
"/home/username/Python/project/lib/python2.7/lib-tk",
"/home/username/Python/project/lib/python2.7/lib-old",
"/home/username/Python/project/lib/python2.7/lib-dynload",
"/usr/lib/python2.7",
"/usr/lib/python2.7/plat-linux2",
"/usr/lib/python2.7/lib-tk",
"/home/username/Python/project/local/lib/python2.7/site-packages",
"/home/username/Python/project/local/lib/python2.7/site-packages/PIL",
"/home/username/Python/project/local/lib/python2.7/site-packages/newrelic-1.8.0.13",
"/home/username/Python/project/lib/python2.7/site-packages/PIL",
]

将这些行放在 wsgi 文件的顶部。

于 2013-05-07T18:54:48.297 回答