[英]Compiling Python 2.7.12 with non-system Openssl on Centos 5
I'm currently trying to get Python 2.7.12 to compile with Openssl 1.0.2h on a Centos 5 host. 我目前正试图在Centos 5主机上使用Openssl 1.0.2h编译Python 2.7.12。
The reason for this is that I need Paramiko 2 to run on this host but that doesn't support the system provided OpenSSL version which is 0.9.8e-fips-rhel5 01 Jul 2008. 原因是我需要Paramiko 2才能在这台主机上运行,但这不支持系统提供的OpenSSL版本,即0.9.8e-fips-rhel5 2008年7月1日。
I've found some great hints and tips on here but it just doesn't seem to work. 我在这里找到了一些很好的提示和技巧,但它似乎没有用。 I'm now posting this in hope that someone will spot what I've done wrong/is missing.
我现在发布这个,希望有人会发现我做错了什么/错过了什么。
For the OpenSSL setup I've done the following: 对于OpenSSL设置,我已完成以下操作:
OPENSSL_ROOT="$HOME/.build/openssl-1.0.1e"
cd /tmp
curl http://www.openssl.org/source/openssl-1.0.2h.tar.gz | tar zxvf -
cd openssl-1.0.2.h
mkdir -p "$OPENSSL_ROOT"
./config no-hw --prefix="$OPENSSL_ROOT" --openssldir=...
make install
Then since I don't want to replace the system installed Python with 2.7.12 I've done the following: 然后因为我不想用2.7.12替换系统安装的Python我已经完成了以下操作:
First I added /usr/local/lib to /etc/ld.so.conf and ran ldconfig. 首先,我将/ usr / local / lib添加到/etc/ld.so.conf并运行ldconfig。
After that I've run: 之后我跑了:
cd /tmp
wget http://python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
tar xf Python-2.7.12.tar.xz
cd Python-2.7.12
./configure CPPFLAGS="-I$OPENSSL_ROOT/include" LDFLAGS="-L$OPENSSL_ROOT/lib" --prefix=/usr/local --enable-unicode=ucs4 --enable-shared
make && make altinstall
This is when I thought I'd have it compiled against the new version of OpenSSL but no, as you can see from the output here: 这是我认为我已经针对新版本的OpenSSL进行编译但是没有,正如您从输出中看到的那样:
[root@an-host openssl-1.0.2h]# python2.7 -c "import ssl; print ssl.OPENSSL_VERSION"
OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
And I'm sure that I'm running the newly compiled version since that is echoed here: 而且我确信我正在运行新编译的版本,因为这是在这里回应的:
[root@an-host openssl-1.0.2h]# python2.7
Python 2.7.12 (default, Aug 1 2016, 11:46:42)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
I have even gone as far as removing openssl-devel with Yum but it still doesn't seem to care/compile against 1.0.2h. 我甚至用Yum删除了openssl-devel,但它仍然似乎不关心/编译1.0.2h。
This is driving me slightly mad at the moment so any input/feedback/help is greatly appreciated. 这让我有点生气,所以任何输入/反馈/帮助都非常感激。
I think I tried to copy too cute solutions and mix and match - tidied up and simplified a bit and got it to work in the end. 我想我试着复制太可爱的解决方案并混合搭配 - 整理并简化了一下,最终让它发挥作用。
This is what I did this time: 这就是我这次做的事情:
Download and install OpenSSL 下载并安装OpenSSL
cd /tmp
curl http://www.openssl.org/source/openssl-1.0.2h.tar.gz | tar zxvf -
cd openssl-1.0.2.h
./config shared --prefix=/usr/local/
make && make install
Set up some environment variables 设置一些环境变量
export LDFLAGS="-L/usr/local/lib/"
export LD_LIBRARY_PATH="/usr/local/lib/"
export CPPFLAGS="-I/usr/local/include -I/usr/local/include/openssl"
Download and install Python 2.7.12 下载并安装Python 2.7.12
wget http://python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
tar xf Python-2.7.12.tar.xz
cd Python-2.7.12
./configure --prefix=/usr/local/ --enable-unicode=ucs4 --enable-shared
make && make altinstall
And now it works as expected, displaying the newer OpenSSL version. 现在它按预期工作,显示较新的OpenSSL版本。
[root@an-host Python-2.7.12]# python2.7
Python 2.7.12 (default, Aug 1 2016, 14:48:09)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> print ssl.OPENSSL_VERSION
OpenSSL 1.0.2h 3 May 2016
However, it still didn't work as expected. 但是,它仍然没有按预期工作。 :( Running the program I got the following error from Paramiko:
:(运行程序我从Paramiko得到以下错误:
RuntimeError: You are linking against OpenSSL 0.9.8, which is no longer support by the OpenSSL project. You need to upgrade to a newer version of OpenSSL.
The solution I found was to uninstall and reinstall the Cryptography bits and pieces by running. 我找到的解决方案是通过运行卸载并重新安装Cryptography位。
pip2.7 uninstall cryptography
pip2.7 install cryptography
After all that - it now works. 毕竟 - 它现在有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.