Web開発用の CentOS5 サーバをメンテせずに数年放置していたところ、 yum が動かなくなっていたので、時代に取り残されたシステムを今更ながらせめて yum が動くように修復します。
この開発用WebサーバはCentOS5→6へのアップグレード手段が無く環境移行になってしまうことから、更新することもなくそのまま何年も使い続けてきました。最近、本番サーバ側でPHP7系が必要になったことから、開発サーバでテストしてみようとPHPのアップグレードをしてみようと思い立ったわけです。まずは現状確認から。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# yum clean all Loaded plugins: fastestmirror Cleaning up Everything Cleaning up list of fastest mirrors [root@apa1 yum.repos.d]# yum repolist Loaded plugins: fastestmirror Determining fastest mirrors base | 1.1 kB 00:00 base/primary | 996 kB 00:01 base 2791/2791 extras | 1.1 kB 00:00 extras/primary | 996 kB 00:01 extras 2791/2791 updates | 1.1 kB 00:00 updates/primary | 996 kB 00:01 updates 2791/2791 Traceback (most recent call last): File "/usr/bin/yum", line 29, in ? yummain.user_main(sys.argv[1:], exit_code=True) File "/usr/share/yum-cli/yummain.py", line 309, in user_main errcode = main(args) File "/usr/share/yum-cli/yummain.py", line 178, in main result, resultmsgs = base.doCommands() File "/usr/share/yum-cli/cli.py", line 349, in doCommands return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds) File "/usr/share/yum-cli/yumcommands.py", line 788, in doCommand base.repos.populateSack() File "/usr/lib/python2.4/site-packages/yum/repos.py", line 260, in populateSack sack.populate(repo, mdtype, callback, cacheonly) File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 168, in populate if self._check_db_version(repo, mydbtype): File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 226, in _check_db_version return repo._check_db_version(mdtype) File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 1226, in _check_db_version repoXML = self.repoXML File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 1399, in <lambda> repoXML = property(fget=lambda self: self._getRepoXML(), File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 1391, in _getRepoXML self._loadRepoXML(text=self) File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 1381, in _loadRepoXML return self._groupLoadRepoXML(text, ["primary"]) File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 1365, in _groupLoadRepoXML if self._commonLoadRepoXML(text): File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 1201, in _commonLoadRepoXML result = self._getFileRepoXML(local, text) File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 974, in _getFileRepoXML cache=self.http_caching == 'all') File "/usr/lib/python2.4/site-packages/yum/yumRepo.py", line 811, in _getFile http_headers=headers, File "/usr/lib/python2.4/site-packages/urlgrabber/mirror.py", line 412, in urlgrab return self._mirror_try(func, url, kw) File "/usr/lib/python2.4/site-packages/urlgrabber/mirror.py", line 398, in _mirror_try return func_ref( *(fullurl,), **kwargs ) File "/usr/lib/python2.4/site-packages/urlgrabber/grabber.py", line 936, in urlgrab return self._retry(opts, retryfunc, url, filename) File "/usr/lib/python2.4/site-packages/urlgrabber/grabber.py", line 854, in _retry r = apply(func, (opts,) + args, {}) File "/usr/lib/python2.4/site-packages/urlgrabber/grabber.py", line 922, in retryfunc fo = URLGrabberFileObject(url, filename, opts) File "/usr/lib/python2.4/site-packages/urlgrabber/grabber.py", line 1010, in __init__ self._do_open() File "/usr/lib/python2.4/site-packages/urlgrabber/grabber.py", line 1093, in _do_open fo, hdr = self._make_request(req, opener) File "/usr/lib/python2.4/site-packages/urlgrabber/grabber.py", line 1202, in _make_request fo = opener.open(req) File "/usr/lib/python2.4/urllib2.py", line 364, in open response = meth(req, response) File "/usr/lib/python2.4/urllib2.py", line 471, in http_response response = self.parent.error( File "/usr/lib/python2.4/urllib2.py", line 396, in error result = self._call_chain(*args) File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain result = func(*args) File "/usr/lib/python2.4/urllib2.py", line 565, in http_error_302 return self.parent.open(new) File "/usr/lib/python2.4/urllib2.py", line 358, in open response = self._open(req, data) File "/usr/lib/python2.4/urllib2.py", line 376, in _open '_open', req) File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain result = func(*args) File "/usr/lib/python2.4/site-packages/M2Crypto/m2urllib2.py", line 82, in https_open h.request(req.get_method(), req.get_selector(), req.data, headers) File "/usr/lib/python2.4/httplib.py", line 810, in request self._send_request(method, url, body, headers) File "/usr/lib/python2.4/httplib.py", line 833, in _send_request self.endheaders() File "/usr/lib/python2.4/httplib.py", line 804, in endheaders self._send_output() File "/usr/lib/python2.4/httplib.py", line 685, in _send_output self.send(msg) File "/usr/lib/python2.4/httplib.py", line 652, in send self.connect() File "/usr/lib/python2.4/site-packages/M2Crypto/httpslib.py", line 55, in connect sock.connect((self.host, self.port)) File "/usr/lib/python2.4/site-packages/M2Crypto/SSL/Connection.py", line 174, in connect ret = self.connect_ssl() File "/usr/lib/python2.4/site-packages/M2Crypto/SSL/Connection.py", line 167, in connect_ssl return m2.ssl_connect(self.ssl, self._timeout) M2Crypto.SSL.SSLError: sslv3 alert handshake failure |
OpenSSL辺りが古すぎてyumが動かないようなので、OpenSSLを手動でソースからコンパイルして入れるしかありません。
まずは現状確認(何もかもが恐ろしく古い)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# rpm -q centos-release centos-release-5-11.el5.centos # uname -a Linux apa1.local 2.6.18-419.el5 #1 SMP Fri Feb 24 22:06:09 UTC 2017 i686 i686 i386 GNU/Linux # openssl version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008 # curl -V curl 7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Protocols: tftp ftp telnet dict ldap http file https ftps Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz # perl -v This is perl, v5.8.8 built for i386-linux-thread-multi |
1.perlを更新
このままではperlがあまりにも古すぎて、OpenSSL現行版をmake config時に次のようなエラーで終了してしまいます。
1 2 3 4 5 6 7 |
# ./config shared enable-ssl2 enable-ssl3 --prefix=/usr 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 v5.10.0 required--this is only v5.8.8, stopped at ./Configure line 12. BEGIN failed--compilation aborted at ./Configure line 12. This system (linux-x86) is not supported. See file INSTALL for details. |
CPANサイトより執筆当時最新版の v5.32.1をダウンロードしますが、こちらのSSLが古いのでhttpsは不可。httpでダウンロードしました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# cd /usr/local/src/ # wget https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz --2021-02-08-- https://www.cpan.org/src/5.0/perl-5.32.1.tar.gz www.cpan.org をDNSに問いあわせています... 151.101.2.132, 151.101.66.132, 151.101.130.132, ... www.cpan.org|151.101.2.132|:443 に接続しています... 接続しました。 SSL による接続が確立できません。 # wget http://www.cpan.org/src/5.0/perl-5.32.1.tar.gz --2021-02-08-- http://www.cpan.org/src/5.0/perl-5.32.1.tar.gz www.cpan.org をDNSに問いあわせています... 151.101.66.132, 151.101.130.132, 151.101.194.132, ... www.cpan.org|151.101.66.132|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 18038522 (17M) [application/x-gzip] `perl-5.32.1.tar.gz' に保存中 100%[=========================================================>] 18,038,522 67.8M/s 時間 0.3s 2021-02-08 (67.8 MB/s) - `perl-5.32.1.tar.gz' へ保存完了 [18038522/18038522] |
ダウンロードしたパッケージを展開し、./configure, make ,make installと進めます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# tar -zxvf perl-5.32.1.tar.gz perl-5.32.1/ -略- # cd perl-5.32.1 # ./Configure -des -Dprefix=/usr/local/perl -Dusethreads -Uversiononly First let's make sure your kit is complete. Checking... -略- Updating makefile... Now you must run 'make'. If you compile perl5 on a different machine or from a different object directory, copy the Policy.sh file from this object directory to the new one before you run Configure -- this will help you with most of the policy defaults. # make -略- make[1]: ディレクトリ `/usr/local/src/perl-5.32.1/utils' から出ます Everything is up to date. Type 'make test' to run test suite. # make install -略- # /usr/local/perl/bin/perl -v This is perl 5, version 32, subversion 1 (v5.32.1) built for i686-linux-thread-multi |
この新しいperlにリンクを張り直してデフォルトとします。
1 2 3 4 5 6 7 8 9 10 11 12 |
# mv /usr/bin/perl /usr/bin/perl.old # ln -s /usr/local/perl/bin/perl /usr/bin/perl # ll /usr/bin/perl* lrwxrwxrwx 1 root root 24 Feb 8 0:00 perl -> /usr/local/perl/bin/perl -rwxr-xr-x 2 root root 14440 Oct 30 2014 perl.old -rwxr-xr-x 2 root root 14440 Oct 30 2014 perl5.8.8 -rwxr-xr-x 1 root root 36840 Oct 30 2014 perlbug -rwxr-xr-x 1 root root 17953 Oct 30 2014 perlcc -rwxr-xr-x 1 root root 224 Oct 30 2014 perldoc -rwxr-xr-x 1 root root 11937 Oct 30 2014 perlivp # perl -v This is perl 5, version 32, subversion 1 (v5.32.1) built for i686-linux-thread-multi |
尚、本項では次の記事に助けられました(Great Tnx!!)。
2.OpenSSLを更新
OpenSSL公式サイトより、執筆当時最新版v1.1.1iのパッケージをダウンロードします(こちらはhttpsでも通りました)。
1 2 3 4 5 6 7 8 9 10 |
# cd /usr/local/src # wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz --2021-02-08-- https://www.openssl.org/source/openssl-1.1.1i.tar.gz www.openssl.org をDNSに問いあわせています... 104.76.133.237, 2600:1417:1000:8a4::c1e, 2600:1417:1000:882::c1e www.openssl.org|104.76.133.237|:443 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 9808346 (9.4M) [application/x-gzip] `openssl-1.1.1i.tar.gz' に保存中 100%[=========================================================>] 9,808,346 51.0M/s 時間 0.2s 2021-02-08 (51.0 MB/s) - `openssl-1.1.1i.tar.gz' へ保存完了 [9808346/9808346] |
ダウンロードしたパッケージを展開し、./configure, make ,make installと進めますが、CPU環境によってはかなり時間が掛かるので、気長に待ちましょう。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# cd /usr/local/src/openssl-1.1.1i # ./config shared enable-ssl2 enable-ssl3 --prefix=/usr Operating system: i686-whatever-linux2 Configuring OpenSSL version 1.1.1i (0x1010109fL) for linux-x86 Using os-specific seed configuration Creating configdata.pm Creating Makefile ********************************************************************** *** *** *** OpenSSL has been successfully configured *** *** *** *** If you encounter a problem while building, please open an *** *** issue on GitHub <https://github.com/openssl/openssl/issues> *** *** and include the output from the following command: *** *** *** *** perl configdata.pm --dump *** *** *** *** (If you are new to OpenSSL, you might want to consult the *** *** 'Troubleshooting' section in the INSTALL file first) *** *** *** ********************************************************************** # make depend # make -略- make[1]: Leaving directory `/usr/local/src/openssl-1.1.1i' # make test -略- All tests successful. Files=158, Tests=2633, 180 wallclock secs ( 1.53 usr 0.16 sys + 160.44 cusr 14.02 csys = 176.15 CPU) Result: PASS make[1]: Leaving directory `/usr/local/src/openssl-1.1.1i' # make install -略- # openssl version OpenSSL 1.1.1i 8 Dec 2020 |
3.curlを更新
curl公式サイトから、執筆当時最新版v7.75のパッケージをダウンロードしようとしますが、https, http共に通りません。仕方ないので、別の母艦PCでダウンロードしてからSCPで転送しました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# wget https://curl.se/download/curl-7.75.0.tar.gz --2021-02-08-- https://curl.se/download/curl-7.75.0.tar.gz curl.se をDNSに問いあわせています... 151.101.130.49, 151.101.194.49, 151.101.2.49, ... curl.se|151.101.130.49|:443 に接続しています... 接続しました。 OpenSSL: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version SSL による接続が確立できません。 # wget http://curl.se/download/curl-7.75.0.tar.gz --2021-02-08-- http://curl.se/download/curl-7.75.0.tar.gz curl.se をDNSに問いあわせています... 151.101.194.49, 151.101.2.49, 151.101.66.49, ... curl.se|151.101.194.49|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 301 Moved Permanently 場所: https://curl.se/download/curl-7.75.0.tar.gz [続く] --2021-02-08 12:48:06-- https://curl.se/download/curl-7.75.0.tar.gz curl.se|151.101.194.49|:443 に接続しています... 接続しました。 OpenSSL: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version SSL による接続が確立できません。 |
転送したパッケージを展開し、./configure, make ,make installと進めます。こちらは一瞬とはいきませんでしたが、OpenSSLほどの時間はかかりませんでした。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# tar xzvf curl-7.75.0.tar.gz # cd curl-7.75.0 # ./configure --enable-libcurl-option --with-ssl=/usr --prefix=/usr checking whether to enable maintainer-specific portions of Makefiles... no -略- Host setup: i686-pc-linux-gnu Install prefix: /usr Compiler: gcc CFLAGS: -Werror-implicit-function-declaration -O2 -Wno-system-headers -pthread CPPFLAGS: LDFLAGS: LIBS: -lssl -lcrypto -lssl -lcrypto -lz -lrt curl version: 7.75.0 SSL: enabled (OpenSSL) SSH: no (--with-{libssh,libssh2}) zlib: enabled brotli: no (--with-brotli) zstd: no (--with-zstd) GSS-API: no (--with-gssapi) TLS-SRP: enabled resolver: POSIX threaded IPv6: no (--enable-ipv6) Unix sockets: enabled IDN: no (--with-{libidn2,winidn}) Build libcurl: Shared=yes, Static=yes Built-in manual: enabled --libcurl option: enabled (--disable-libcurl-option) Verbose errors: enabled (--disable-verbose) Code coverage: disabled SSPI: no (--enable-sspi) ca cert bundle: /etc/pki/tls/certs/ca-bundle.crt ca cert path: no ca fallback: no LDAP: no (--enable-ldap / --with-ldap-lib / --with-lber-lib) LDAPS: no (--enable-ldaps) RTSP: enabled RTMP: no (--with-librtmp) Metalink: no (--with-libmetalink) PSL: no (libpsl not found) Alt-svc: enabled HTTP1: enabled (--with-hyper) HTTP2: no (--with-nghttp2) HTTP3: no (--with-ngtcp2, --with-quiche) ECH: no (--enable-ech) Protocols: DICT FILE FTP FTPS GOPHER GOPHERS HTTP HTTPS IMAP IMAPS MQTT POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP Features: AsynchDNS HTTPS-proxy NTLM NTLM_WB SSL TLS-SRP UnixSockets alt-svc libz # make -略- # make install -略- # curl -V curl 7.75.0 (i686-pc-linux-gnu) libcurl/7.75.0 OpenSSL/1.1.1i zlib/1.2.3 Release-Date: 2021-02-03 Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: alt-svc AsynchDNS HTTPS-proxy Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets |
4.レポジトリを整理してyum確認
yumで参照されるレポジトリは、次のように格納されています。
1 2 3 4 5 6 |
# ls -l /etc/yum.repo.d/ -rw-r--r-- 1 root root 1991 May 19 2016 CentOS-Base.repo -rw-r--r-- 1 root root 647 May 19 2016 CentOS-Debuginfo.repo -rw-r--r-- 1 root root 630 May 19 2016 CentOS-Media.repo -rw-r--r-- 1 root root 6259 May 19 2016 CentOS-Vault.repo -rw-r--r-- 1 root root 289 May 19 2016 CentOS-fasttrack.repo |
さすがにサポートもとうに切れていることから、特にサードパーティのレポジトリはリンク切れになっていないか、repoファイル内で次のようにデフォルト無効化してから、yumを完走させます。
1 |
enabled=0 |
最後にキャッシュをクリアしてからyumを更新し、エラー無く完走することを確認出来ました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# yum clean all Loaded plugins: fastestmirror Cleaning up Everything Cleaning up list of fastest mirrors # yum update Loaded plugins: fastestmirror Determining fastest mirrors base | 1.1 kB 00:00 base/primary | 996 kB 00:01 base 2791/2791 extras | 1.1 kB 00:00 extras/primary | 996 kB 00:01 extras 2791/2791 updates | 1.1 kB 00:00 updates/primary | 996 kB 00:01 updates 2791/2791 Setting up Update Process No Packages marked for Update |
次回はそもそもの命題である、PHPのバージョンアップを試みる予定ですが、ソースから入れるのであればサーバごとリプレースするつもりでいるので、yumでCentOS5用に使えるレポジトリが有るかどうかにかかっています。