How to compile mod_wsgi 4.5.3 with Python3.5.2 und

2019-02-19 07:22发布

问题:

I tried ./configure for mod_wsgi 4.5.3 like below:

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

Where /opt/Python352 folder is installed with python3.5.2.

However in CentOS 7 the "configure" always builds the mod_wsgi with binary "python"(corresponding to python2.75) not with binary "python3" or "python3.5".

Requirement is to get the .so file, the latest for mod_wsgi 4.5.3, compiled using python3.5.2 and load this in Apache/2.4.6 under CentOS 7.

Thanks.

回答1:

Here's an exact dump of what I use for CentOS 7.2. You can probably do without a lot of the pre-reqs, but I figured I'd include them since many are handy to have:

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

I couldn't see an obvious problem with your question given the information, but figured a complete working example would help.