LoginSignup
9
2

Ubuntu 18.04でRuby 2.0.0をビルドする

Last updated at Posted at 2018-05-28

Ubuntu 18.04で普通に生活していると1.1.0以上のOpenSSLがインストールされるが、その状態で rbenv install 2.0.0-p648 をやるとOpenSSLのヘッダで #error となりビルドに失敗する。
基本的にはEOLであるRuby 2.0.0を使うのをやめるのが正しいのだが、現在のtrunkがRuby 2.0.0の何倍高速かを調べるためにビルドしなければならなかったため、方法をメモしておく。

OpenSSL 1.0.2をインストールする

aptの設定を書いてグローバルにインストールするOpenSSLのバージョンを下げることもできるが、まあ普通にRuby 2.0.0をビルドする以外では最新のものを使いたいのでソースからビルドして適当なディレクトリ(ここでは /opt/openssl-1.0.2o)に置いておくことにする。

https://www.openssl.org/source/ からOpenSSL 1.0.2をダウンロードし、ビルドする。

# openssl-1.0.2u が最後のリリース (2019)
wget https://www.openssl.org/source/openssl-1.0.2u.tar.gz
tar xvzf openssl-1.0.2u.tar.gz
cd openssl-1.0.2o
./config --prefix=/opt/openssl-1.0.2u shared
make -j4
sudo make install

--with-openssl-dir を指定してRuby 2.0.0をビルドする

# rbenv (ruby-build)
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/opt/openssl-1.0.2u" rbenv install 2.0.0-p648

# ruby-install
PATH="/opt/bison-3.2.4/bin:${PATH}" ruby-install 2.0.0-p648 -- --with-openssl-dir=/opt/openssl-1.0.2u

これで無事ビルドできた。

9
2
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
9
2