0
0

Redhat Enterprise Linux Server 6.3をVirtualboxへインストールしてPython3.7.17をビルドする手順

Posted at

はじめに

古いOSでPython3.7をインストール必要があり、環境構築からPython3.7.17をビルドするまでの手順をまとめます。

環境構築

Windows10にVirtualboxをインストールし、仮想環境にRedhat Enterprise Linux Server 6.3をインストールします。

Redhat Enterprise Linux Server 6.3のインストールメディア(ISOファイル)はRedhatのサポートページへログインしてダウンロードします。

Virtualbox 7.0.18ではインストールDVDが起動しませんでした。
Virtualbox 6.1.50は起動できました。

RedhatのインストールはSoftware Developmentを選択します。
デフォルトのBasicではビルドに必要なソフトウェア(gccなど)がインストールされません。

RedhatへSSHログインする

macOSからRedhatへSSHでアクセスするとエラーが表示されました。

$ ssh root@192.168.3.128
Unable to negotiate with 192.168.3.128 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

オプションを付けてsshコマンドを実行します。

ssh -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=ssh-dss,ssh-rsa root@192.168.3.128

Python3.7.17をビルドする

Python3.7.17のビルドに必要なソフトウェアをインストールします。
rootユーザで行う前提で手順を記載します。

  • openssl 1.1.1

cd
tar xvzf openssl-1.1.1w.tar.gz
mv openssl-1.1.1w /usr/local/openssl
cd /usr/local/openssl
./config --shared --prefix=/usr/local/
make
make install
echo "/usr/local/openssl" > /etc/ld.so.conf.d/openssl.conf
ldconfig
  • tcl8.6.14

cd
tar xvzf tcl8.6.14.tar.gz
cd tcl8.6.14/unix
./configure --prefix=/usr/local
make
make install
  • tk8.6.14

cd
tar xvzf tk8.6.14.tar.gz
cd tk8.6.14/unix
./configure --prefix=/usr/local
make
make install
echo "/usr/local/lib" > /etc/ld.so.conf.d/tcltk.conf
ldconfig
  • libffi

cd
tar xvzf libffi-3.4.6.tar.gz
cd libffi-3.4.6
./configure --prefix=/usr/local
make
make install
echo "/usr/local/lib64" > /etc/ld.so.conf.d/libffi.conf
ldconfig

-- xz

cd
tar xvzf xz-5.4.6.tar.gz
cd xz-5.4.6
./configure
make
make install
  • Python3.7.17

cd
tar xvzf Python-3.7.17.tgz
cd Python-3.7.17
export CFLAGS="-I/usr/local/include -I/usr/local/openssl/include"
export LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -L/usr/local/openssl/lib"
export LD_RUN_PATH=/usr/local/lib64:/usr/local/lib:/usr/local/openssl/lib:/usr/lib:/usr/lib64
export LD_LIBRARY_PATH=/usr/local/openssl/lib:/usr/local/lib64:/usr/local/lib:/usr/lib:/usr/lib64
export PKG_CONFIG_PATH=/usr/local/ssl/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib:/usr/lib64/pkgconfig
./configure --with-openssl=/usr/local/openssl --enable-optimizations
make
make altinstall

参考情報

Python3.7をビルドする場合、OpenSSL 1.0.2、または、1.1.1以上が必要だが、1.0.2をインストールすると、urllib3でエラーが出る。

ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2u  20 Dec 2019'. See: https://github.com/urllib3/urllib3/issues/2168
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0