繁体   English   中英

使用Centos 5上的非系统Openssl编译Python 2.7.12

[英]Compiling Python 2.7.12 with non-system Openssl on Centos 5

我目前正试图在Centos 5主机上使用Openssl 1.0.2h编译Python 2.7.12。

原因是我需要Paramiko 2才能在这台主机上运行,​​但这不支持系统提供的OpenSSL版本,即0.9.8e-fips-rhel5 2008年7月1日。

我在这里找到了一些很好的提示和技巧,但它似乎没有用。 我现在发布这个,希望有人会发现我做错了什么/错过了什么。

对于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

然后因为我不想用2.7.12替换系统安装的Python我已经完成了以下操作:

首先,我将/ usr / local / lib添加到/etc/ld.so.conf并运行ldconfig。

之后我跑了:

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

这是我认为我已经针对新版本的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

而且我确信我正在运行新编译的版本,因为这是在这里回应的:

[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.

我甚至用Yum删除了openssl-devel,但它仍然似乎不关心/编译1.0.2h。

这让我有点生气,所以任何输入/反馈/帮助都非常感激。

我想我试着复制太可爱的解决方案并混合搭配 - 整理并简化了一下,最终让它发挥作用。

这就是我这次做的事情:

下载并安装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

设置一些环境变量

export LDFLAGS="-L/usr/local/lib/"
export LD_LIBRARY_PATH="/usr/local/lib/"
export CPPFLAGS="-I/usr/local/include -I/usr/local/include/openssl"

下载并安装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

现在它按预期工作,显示较新的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

但是,它仍然没有按预期工作。 :(运行程序我从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.

我找到的解决方案是通过运行卸载并重新安装Cryptography位。

pip2.7 uninstall cryptography
pip2.7 install cryptography

毕竟 - 它现在有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM