CentOS 5.4 で Pyenv インストールして Python をバージョンアップできる??

先日、mLab から MongoDB Atlas への移行で、ローカル開発環境では Python や Scrapy のバージョンアップをした。結構苦労したがなんとか解決。ただ、次はサーバで対応する必要がある。

このサーバなんと CentOS 5.4。茨の道な気配が…。軽く調べると、2018年に Pyenv をインストールしている記事を見つけたが、今でも適用可能だろうか?ちなみにかなり無理矢理な方法らしく、OS バージョンアップを選んだほうが良いのでは?と頭をよぎる。

https://qiita.com/selfnavi/items/96eca90a34122ae4a931

インストールされている openssl のバージョンを確認すると、0.9.8e-40.el5_11。うーん、ヤバそう。

ただ他にも Rails のアプリを動かしていたりして、気軽に環境を触れない状態になっているのが厄介。いい加減 Docker 化したいなという想いもある。選択肢を整理する。

  • Pyenv 使う
    • CentOS 5 にインストール
    • CentOS 6 にバージョンアップしてインストール
      • 手動バージョンアップ
      • 別サーバ契約して移行
    • CentOS 7 にバージョンアップしてインストール
  • Docker を使う
    • CentOS 5 にインストール
    • CentOS 6 にバージョンアップしてインストール
    • CentOS 7 にバージョンアップしてインストール
    • Heroku で
    • GCP で?
    • AWS で?

cron タスク形式なのだが Heroku で動かせるのだろうか?Web API を用意して、別のサービスから1日1回呼ぶというのも考えられるが。

このサーバでは他にも下記が動いている。

  • Apache
  • MySQL
  • Rails
  • Git
  • Subversion

うーん、まずは OS バージョンアップはだいぶ時間がかかりそうなので、まずは CentOS 5 で Pyenv のインストールを試みる。

上記記事を参考に進めるが、openssl のビルドで早速エラー。perl のバージョンが古いらしい。

# CFLAGS=-fPIC ./config shared
Operating system: i686-whatever-linux2
Perl v5.10.0 required--this is only v5.8.8, stopped at ./Configure line 12.
BEGIN failed--compilation aborted at ./Configure line 12.

まずは perl のバージョンアップからか。

https://www.itcore.jp/tips/centos5_perl.php

perl を yum erase すると色々一緒に消えてしまった…

Dependency Removed:
aspell.i386 12:0.60.3-7.1 
aspell-en.i386 50:6.0-2.1 
curl-devel.i386 0:7.15.5-9.el5_6.2 
git.i386 0:1.7.12.4-1.el5.rf
httpd-devel.i386 0:2.2.3-91.el5.centos 
lftp.i386 0:3.7.11-7.el5 
libidn-devel.i386 0:0.6.5-1.1 
lm_sensors.i386 0:2.10.7-4.el5
mod_dav_svn.i386 0:1.6.11-11.el5_9 
mysql.i386 0:5.0.77-4.el5_5.5 
mysql-devel.i386 0:5.0.77-4.el5_5.5 
mysql-server.i386 0:5.0.77-4.el5_5.5
net-snmp.i386 1:5.3.2.2-7.el5_4.2 
net-snmp-utils.i386 1:5.3.2.2-7.el5_4.2 
perl-CGI-Session.noarch 0:4.42-1.el5.rf 
perl-Convert-ASN1.noarch 0:0.20-1.1
perl-DBD-MySQL.i386 0:3.0007-2.el5 
perl-DBI.i386 0:1.52-2.el5 
perl-Git.i386 0:1.7.12.4-1.el5.rf 
perl-String-CRC32.i386 0:1.4-2.fc6
perl-URI.noarch 0:1.35-3 
perl-YAML.noarch 0:0.72-1.el5.rf 
php.i386 0:5.1.6-27.el5_5.3 
php-cli.i386 0:5.1.6-27.el5_5.3
php-mysql.i386 0:5.1.6-27.el5_5.3 
samba.i386 0:3.0.33-3.15.el5_4.1 
samba-client.i386 0:3.0.33-3.15.el5_4.1 
samba-swat.i386 0:3.0.33-3.15.el5_4.1
sharutils.i386 0:4.6.1-2 
smadmin.i386 0:1.0-003 
stunnel.i386 0:4.15-2.el5.1 
subversion.i386 0:1.6.11-11.el5_9
subversion-perl.i386 0:1.6.11-11.el5_9 
vim-enhanced.i386 2:7.0.109-6.el5

とりあえず下記の手順でインストールを進める。

https://www.itcore.jp/tips/centos5_perl.php

Perl 5.10.0 を別マシンでダウンロードしてビルド進めるも、make test でエラー。

Failed 1 test out of 1387, 99.93% okay.
../lib/Time/Local.t
Since not all tests were successful, you may want to run some of
them individually and examine any diagnostic messages they produce.
See the INSTALL document's section on "make test".
You have a good chance to get more information by running
./perl harness
in the 't' directory since most (>=80%) of the tests succeeded.
You may have to set your dynamic library search path,
LD_LIBRARY_PATH, to point to the build directory:
setenv LD_LIBRARY_PATH pwd; cd t; ./perl harness
LD_LIBRARY_PATH=pwd; export LD_LIBRARY_PATH; cd t; ./perl harness
export LD_LIBRARY_PATH=pwd; cd t; ./perl harness
for csh-style shells, like tcsh; or for traditional/modern
Bourne-style shells, like bash, ksh, and zsh, respectively.
u=2.41 s=1.07 cu=186.56 cs=17.27 scripts=1387 tests=188246
make[2]: *** [_test_tty] Error 1
make[2]: Leaving directory /usr/local/src/perl-5.10.0' make[1]: *** [_test] Error 2 make[1]: Leaving directory/usr/local/src/perl-5.10.0'
make: *** [test] Error 2

失敗しているテストを下記で再実行してみる。

./perl -wT /lib/Time/Local.t

日付に関するエラーっぽい。

1..140
Day too big - 36526 > 24853
Cannot handle date (0, 0, 0, 2, 0, 2070) at lib/Time/Local.t line 99
Looks like your test died before it could output anything.

調べると 32bit CPU だと桁あふれするみたいな情報が多数。「Time::Localモジュールでの2038年問題」らしい…。

https://www.h-fj.com/blog/archives/2010/07/08-130433.php

うーん、気にしつつもインストールしてみよう。make install し、perl -v すると 5.10.0 になった。

続いて openssl で CFLAGS=-fPIC ./config shared すると今度は成功。make install も成功したが、openssl -v すると下記のエラー。

openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

大丈夫なのだろうか?後の手順で解消されるのか?

気になりつつも curl のインストールに進む。インストールは何事もなく完了したが、curl -V すると OpenSSL/1.0.2a となっており、古い OpenSSL を見ている…。ただ yumでインストールされていた 0.9.8 とも違うバージョン…。

curlビルド時に指定していた/usr/local/ssl/libを見ると、確かに1.0.2aになっている。ここが置き換えられていないのが問題か。ただ1.0.2aならもしかしていけるかもという淡い期待も。

そこでPyenvインストールに進むと問題なくインストールできた!pyenv-virtualenvも公式手順のgit cloneをcurl -oでダウンロードしてからunzipすればインストールできたので、pip installに進む。

するとpip install scrapy==1.8 で下記のエラー。

cc1: error: unrecognized command line option "-Wno-error=sign-conversion"

32bit の CentOS 5.4 はやっぱり無理があるか…。

https://github.com/pyca/cryptography/issues/5088

コメントを残す