Jruby 1.7.3 on FreeBSD 9.1
Hi all,
Kinda torn between Jruby and Groovy, so I figured I'll write down the steps I took to get Jruby working on FreeBSD 9.1.
Prerequisites:
1. Make sure bash is installed - it looks like Jruby needs it even if you don't actually use it - while you're on it also install curl for testing with Sinatra (you can also use a browser)
pkg_add -r bash curl
1. Download jruby (17MB)
cd /tmp; wget http://jruby.org.s3.amazonaws.com/downloads/1.7.3/jruby-bin-1.7.3.tar.gz
2. Untar under /usr/local:
tar xzf jruby-bin-1.7.3.tar.gz -C /usr/local/
3. Set Path: (C shell only)
set path=(/usr/local/jruby-1.7.3/bin $path)
4. Set the path permanently: (C Shell only)
echo 'set path=(/usr/local/jruby-1.7.3/bin $path)' >> ~/.cshrc
5. Test by going to the home dir and getting the jruby version:
cd ~ ; pwd; jruby -v
You should get:
/root
jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on OpenJDK Client VM 1.7.0_09-b05 [FreeBSD-i386]
6. Install the Sinatra gem:
gem install sinatra --no-ri --no-rdoc
Note: Look here for what the --no-rdoc switch does
7. Try out the most basic sinatra example from: http://www.sinatrarb.com/
First change to the /root directory:
cd /root
Use your favorite editor to create a file called sinatra101.rb:
ee sinatra101.rb
Paste the following contents inside:
require 'sinatra'
get '/hi' do
"Hello World!n"
end
8. Run it with:
jruby sinatra101.rb -o 0.0.0.0
Sinatra starting up looks like this:
[2013-04-20 17:41:04] INFO WEBrick 1.3.1
[2013-04-20 17:41:04] INFO ruby 1.9.3 (2013-02-21) [java]
== Sinatra/1.4.2 has taken the stage on 4567 for development with backup from WEBrick
[2013-04-20 17:41:04] INFO WEBrick::HTTPServer#start: pid=8483740 port=4567
9. In a different window try the following:
ps aux | egrep -i 'ruby|java' | grep -v grep
You should get something like this:
root 765 0.0 11.5 670356 58172 0 I+ 5:24PM 0:07.11 /usr/local/openjdk7/bin/java -Xmx500m -Xss2048k -Djffi.boot
As you can see there's no ruby process running! It runs as a Java process.
10. Test sinatra with curl:
curl 127.0.0.1:4567/hi
You should get:
Hello World!