Installing jruby on CentOS 6.x and building an RPM package for it
In my last post, I discussed the performance gains on a multicore system when switching from MRI Ruby to Jruby.
However, in that post I used RVM to install Jruby and that in some cases may not be the best choice.
Here's how I installed Jruby in CentOS 6.x and created an RPM package out of it to make installation faster in the future.
1. First install OpenJDK 1.8.0.
yum -y install java-1.8.0-openjdk
2. Then download the latest Jruby source code - at the time of writing, that's 9.1.6.0.
cd /tmp/
curl -LO https://s3.amazonaws.com/jruby.org/downloads/9.1.6.0/jruby-bin-9.1.6.0.tar.gz
tar -xzf jruby-bin-*.tar.gz -C /
3. To create an RPM package we'll use FPM. To use FPM, we need Ruby :) So I'm installing my personal RPM repository to install Ruby quickly:
yum -y install http://rpm.chaidas.com/rpm.chaidas.com-0.1-1.x86_64.rpm
yum -y install ruby rpm-build libffi-devel make gcc
4. Cool, now install the FPM gem:
gem install fpm --no-ri --no-rdoc
5. Nice - now go to the Jruby directory and delete the samples (we don't need them):
cd /jruby-*
# delete unnecessary dirs
rm -r -f -v samples/ tool/
6. Create the RPM package:
fpm --verbose -v 9.1.6.0 -n jruby -d java-1.8.0-openjdk -s dir -t rpm .=/usr
7. Now remove the MRI Ruby and install Jruby:
yum -y remove ruby\*
yum -y install jruby-9.1.6.0-1.x86_64.rpm
8. Check the version of Jruby using the jruby -v
command:
[root@jruby helpy-1.0]# jruby -v
jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 OpenJDK 64-Bit Server VM 25.111-b15 on 1.8.0_111-b15 +jit [linux-x86_64]
And we're done!