簡體   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