我似乎尝试了一切,但未能在 32 位模式下运行 Python。
所以这是我的情况:
我正在运行 OSX 10.8。我开发了必须连接到 Oracle 10g2 数据库的 CherryPy 应用程序。有一个众所周知的问题阻止 CX_Oracle 在 64 位中工作,因此要求在 32 位中运行。
<IfModule wsgi_module> 
<Directory "/Library/WebServer/WSGI-Executables">
AllowOverride None
Options None FollowSymLinks
Order allow,deny
Allow from all
SetEnv CONFIG_PATH /Users/bioffe/src/Icap/trunk/cgi-bin
SetEnv ORACLE_HOME /Applications/ORACLE/instantclient_10_2
SetEnv TNS_ADMIN /Applications/ORACLE/instantclient_10_2
SetEnv LD_LIBRARY_PATH /Applications/ORACLE/instantclient_10_2
SetEnv DYLD_LIBRARY_PATH /Applications/ORACLE/instantclient_10_2
SetEnv VERSIONER_PYTHON_PREFER_32_BIT yes
</Directory>
WSGIPythonHome  /usr/local/bin/python2.7-32
WSGIPythonPath /Library/WebServer/WSGI-Executables
WSGIScriptAlias /etc  /Library/WebServer/WSGI-Executables/ETCConfWebApp.py
#WSGIDaemonProcess etc_config user=bioffe group=wheel threads=4 python_path=/Library/Python/2.7/site-packages/
ProxyPreserveHost On
SetEnv VERSIONER_PYTHON_PREFER_32_BIT yes
</IfModule>
应用程序代码
@cherrypy.expose
def index(self):
    result = ''
    for key, value in os.environ.items():
        result += key + '=' + value + '\r\n'
    cherrypy.response.headers['Content-Type']= 'text/plain'
    result += '*' * 10
    result += '\rCurrent Dir = %s \r' % os.getcwd()
    result += '__file__ = %s \r' % __file__
    result += 'PID=%d \r' %  os.getpid()
    result += 'PPID=%d \r' % os.getppid()
    result += 'UID=%d \r' % os.getuid()
    import threading
    th = threading.current_thread()
    result += "ThreadID=%d name=%s \r" %(th.ident,th.name)
    result += "ThreadPool Size=%d \r" %(cherrypy.server.thread_pool)
    result += "ThreadPool Max Size=%d \r" %(cherrypy.server.thread_pool_max)
    import sys
    result += "%s \r" %(sys.version)
    result += "%d \r" %(sys.maxint)
输出
PATH=/usr/bin:/bin:/usr/sbin:/sbin
**********
Current Dir = /Library/WebServer/WSGI-Executables 
__file__ = /Library/WebServer/WSGI-Executables/ETCConfWebApp.py 
PID=16170 
PPID=16167 
UID=70 
ThreadID=140735313402208 name=MainThread 
ThreadPool Size=10 
ThreadPool Max Size=-1 
2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] 
9223372036854775807 <- 64 bit, I want to see 32-bit's 2147483647 
这是迄今为止尝试过的:
- 通过设置环境变量强制 Python - 导出 VERSIONER_PYTHON_PREFER_32_BIT=是 - WSGI_mod 忽略了这一点。os.environ 只包含一个PATH环境变量 
- 通过设置默认值强制 Python 并使其可供 _www(70) 用户访问。 - 默认写入 com.apple.versioner.python Prefer-32-Bit -bool 是 
- 从中创建 virtualenv 和 lipo Thin i386 可执行文件 - WSGIPythonHome /usr/local/bin/python2.7-32 
- 要将瘦可执行文件创建到默认的 python 环境中,没有用。 
- 使用 python2.7-32 的头文件和 *.sos 编译 mod_wsgi 链接。 
没有任何效果。我想知道有人可以对这个问题有所了解。
奖金问:我添加了
WSGIDaemonProcess etc_config user=bioffe group=wheel threads=4 python_path=/Library/Python/2.7/site-packages/
我看到使用 UID bioffe 运行的额外 https 进程,但是我的应用程序仍由具有 UID _www 的 httpd 进程处理。为什么我的请求正在由不同的 httpd 进程处理?