如何在centos7,Apache / 2.4.6下使用Python3.5.2编译mod_wsgi 4.5.3

时间:2016-07-07 22:29:21

标签: python mod-wsgi wsgi python-3.5

我为mod_wsgi 4.5.3尝试了./configure,如下所示:

./ configure --with-python = / opt / Python352 / bin

使用python3.5.2安装/ opt / Python352文件夹。

然而在CentOS 7中,“configure”总是使用二进制“python”(对应于python2.75)而不是二进制“python3”或“python3.5”来构建mod_wsgi。

要求获取.so文件,最新的mod_wsgi 4.5.3,使用python3.5.2编译并在CentOS 7下的Apache / 2.4.6中加载。

感谢。

1 个答案:

答案 0 :(得分:5)

这是我用于CentOS 7.2的精确转储。你可能没有很多预先要求,但我想我会把它们包括在内,因为很多都很方便:

echo 'Python 3.5.2 is not installed, installing Python 3 pre-requisites...'
yum -y groupinstall development

echo 'Installing extra packages for Python...'
yum -y install zlib-devel openssl-devel sqlite-devel bzip2-devel python-devel openssl-devel libffi-devel openssl-perl libjpeg-turbo-devel zlib-devel giflib ncurses-devel gdbm-devel xz-devel tkinter readline-devel tk tk-devel

echo 'Installing Python 3.5.2...'
wget -q 'https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz'
tar -xzf 'Python-3.5.2.tgz'
cd ./Python-3.5.2
CXX=g++ ./configure --enable-shared
make

echo 'Moving to alternate location to keep system Python version intact...'
make altinstall
cd ..
rm Python-3.5.2.tgz
rm -rf ./Python-3.5.2
ln -fs /usr/local/bin/python3.5 /usr/bin/python3.5
echo "/usr/local/lib/python3.5" > /etc/ld.so.conf.d/python35.conf
echo "/usr/local/lib" >> /etc/ld.so.conf.d/python35.conf
ldconfig

echo 'Now, install mod_wsgi...'
wget -q "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=/usr/local/bin/python3.5
make
make install

鉴于这些信息,我无法看到你问题的明显问题,但想出一个完整的工作例子会有所帮助。