mod_wsgi 的WSGIPythonHome 到底是起什么作用的?

155 views
Skip to first unread message

alva bai

unread,
Jul 23, 2009, 11:25:39 PM7/23/09
to python-cn`CPyUG`华蟒用户组(中文Py用户组)
Ubuntu9.04默认的Python版本是2.6的,为了安装repoze.plone,就又安装了Python2.4;
用 virtualenv --python=python2.4 --no--site-pachages /datarepos/plone3/
python 创建了虚拟环境,然后执行
/datarepos/plone3/python/bin/easy_install 安装了repoze.plone,repoze.plone安
装完成后,配置好Apache2+mod_wsgi,配置文件如下:

zope2.wsgi:

import os
from paste.deploy import loadapp

ini = '/datarepos/plone3/python/etc/zope2.ini'
application = loadapp('config:%s' % ini)


Apache2.conf:

WSGIPythonHome /datarepos/plone3/python
WSGIDaemonProcess tmp threads=1 processes=4 maximum-requests=10000
python-path=/datarepos/plone3/python/lib/python2.4/site-packages

<VirtualHost *:80>
ServerName wiki.inc.tech

ErrorLog /var/log/apache2/plone_error.log
#LogLevel info
CustomLog /var/log/apache2/plone_access.log combined

WSGIScriptAlias /site /datarepos/plone3/python/bin/zope2.wsgi
WSGIProcessGroup tmp
WSGIPassAuthorization On
SetEnv HTTP_X_VHM_HOST http://wiki.inc.tech/site
SetEnv PASTE_CONFIG /datarepos/plone3/python/etc/zope2.ini
</VirtualHost>

查看log文件发现运行出错,然后我修改了zope2.wsgi文件:

import sys
def application(environ, start_response):
status = '200 OK'
output = sys.version
# output = str(sys.path)

response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]

发现sys.version显示是还是Python2.6,看资料WSGIPythonHome /datarepos/plone3/python
就是指定WSGI的python的运行环境的,怎么没有起作用?

请各位给我指指我的问题;

alva bai

unread,
Jul 24, 2009, 11:18:39 AM7/24/09
to python-cn`CPyUG`华蟒用户组(中文Py用户组)
没有那位给点建议吗?

On 7月24日, 上午11时25分, alva bai <alva...@gmail.com> wrote:
> Ubuntu9.04默认的Python版本是2.6的,为了安装repoze.plone,就又安装了Python2.4;
> 用 virtualenv --python=python2.4 --no--site-pachages /datarepos/plone3/
> python 创建了虚拟环境,然后执行
> /datarepos/plone3/python/bin/easy_install 安装了repoze.plone,repoze.plone安
> 装完成后,配置好Apache2+mod_wsgi,配置文件如下:
>
> zope2.wsgi:
>
> import os
> from paste.deploy import loadapp
>
> ini = '/datarepos/plone3/python/etc/zope2.ini'
> application = loadapp('config:%s' % ini)
>
> Apache2.conf:
>
> WSGIPythonHome /datarepos/plone3/python
> WSGIDaemonProcess tmp threads=1 processes=4 maximum-requests=10000
> python-path=/datarepos/plone3/python/lib/python2.4/site-packages
>
> <VirtualHost *:80>
> ServerName wiki.inc.tech
>
> ErrorLog /var/log/apache2/plone_error.log
> #LogLevel info
> CustomLog /var/log/apache2/plone_access.log combined
>
> WSGIScriptAlias /site /datarepos/plone3/python/bin/zope2.wsgi
> WSGIProcessGroup tmp
> WSGIPassAuthorization On
> SetEnv HTTP_X_VHM_HOSThttp://wiki.inc.tech/site

ljpsfree

unread,
Jul 24, 2009, 1:00:33 PM7/24/09
to pyth...@googlegroups.com
hi

文档(http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonHome)中提到了三点需要注意的地方,你需要重新检查一下。

1. Note that the Python installation being referred to using this
directive must be the same major/minor version of Python that mod_wsgi
was compiled for. If you want to use a different version of
major/minor version of Python than currently used, you must recompile
mod_wsgi against the alternate version of Python.
确认mod_wsgi是否是python2.4编译的

2. This directive is the same as having set the environment variable
PYTHONHOME in the environment of the user that Apache executes as. If
this directive is used it will override any setting of PYTHONHOME in
the environment of the user that Apache executes as.
确认apache用户的环境变量中是否有PYTHONHOME

×3. This directive will have no affect if mod_python is being loaded
into Apache at the same time as mod_wsgi as mod_python will in that
case be responsible for initialising Python.
我之前碰到过这个,也是郁闷了一阵。检查apache是否加载了mod_python模块,如果你是按照ubuntu的习惯配置的,那么检查/etc/apache2/mod-enabled/目录下面是否有mod_python相关配置(如果我没记错的话)。

祝你好运!


2009/7/24 alva bai <alv...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages