这是这个问题的一个延续,但它有所偏差,所以我开始了一个新的问题。 我想使用Python 2.5而不是OS X的默认2.6。 我已经设置了我的terminal和whatnot,但每当Apache运行它给我以下错误输出:
[Thu Jun 23 00:01:42 2011] [warn] Init: Session Cache is not configured [hint: SSLSessionCache] [Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Compiled for Python/2.5.4. [Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Runtime using Python/2.6.1. [Thu Jun 23 00:01:42 2011] [notice] Digest: generating secret for digest authentication ... [Thu Jun 23 00:01:42 2011] [notice] Digest: done [Thu Jun 23 00:01:42 2011] [notice] Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1 configured -- resuming normal operations
我已经设置了WSGIPythonPath以匹配sys.path在python shell中给我的东西:
WSGIPythonPath /System/Library/Frameworks/Python.framework/Versions/2.5
仍然没有运气。 想法?
您应该使用以下指令,具体取决于您使用的mod_wsgi版本
对于mod_wsgi 1.x:
WSGIPythonExecutable /path/to/python/2.5/exe
对于mod_wsgi 2.x:
WSGIPythonHome /path/to/python/2.5/exe/directory
WSGIPythonPath
仅用于将自己的库添加到WSGI上下文中的Python路径中。
链接到文档: http : //code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonExecutable
[Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Compiled for Python/2.5.4. [Thu Jun 23 00:01:42 2011] [warn] mod_wsgi: Runtime using Python/2.6.1.
这两行告诉你,mod_wsgi是为错误的Python版本编译的,所以你需要用正确的--with-python
指令重新编译它。 请参阅http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide#Configuring_The_Source_Code 。
下面是我如何解决在CentOS 6.7上的类似问题,因为默认是Python 2.6,我需要安装Python 2.7来支持Django网站。
首先我用yum
安装Python 2.7:
yum install python27 python27-python-devel python27-MySQL-python
Python 2.7的安装路径是/opt/rh/python27/root/usr/bin/python
然后我们需要用新路径重新编译mod_wsgi,这里是命令:
wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.4.21.tar.gz tar -xzf 4.4.21.tar.gz cd mod_wsgi-4.4.21 ./configure --with-python=/opt/rh/python27/root/usr/bin/python LDFLAGS="-R/opt/rh/python27/root/usr/lib64" make && make install service httpd restart tail /var/log/httpd/error_log
这里的关键是,mod_wsgi需要在我的Python 2.7安装中找到/opt/rh/python27/root/usr/lib64
下的libpython2.7.so
。
在我的安装中的另一个重要的注意事项是,我必须安装python27-MySQL-python
与yum
,否则我得到一个错误,当与pip
安装它如下:
pip install MySQL-python