"Hello World" with Sinatra and Puma using MRI and Jruby
Hello internet,
A long time ago, I wrote about installing Jruby 1.7.3 on FreeBSD 9.1. Recently I was looking to build a small Sinatra application on CentOS 6.x.
Here's my notes on how I got it done.
MRI Ruby first:
1. Install MRI Ruby:
I used my own repository so I don't spend time rebuilding Ruby from source:
yum -y install http://rpm.chaidas.com/rpm.chaidas.com-0.1-1.x86_64.rpm
yum -y install ruby
Check that Ruby was installed correctly:
ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
2. Install some dependencies:
yum -y install gcc
3. Install the sinatra and puma gems:
gem install sinatra puma --no-ri --no-rdoc
4. Add a file called sinatra-puma.rb with content:
require 'sinatra'
get '/' do
"Hello World!"
end
5. Run Puma:
ruby sinatra-puma.rb -s Puma -p 80 -o 0.0.0.0
Do the same thing with Jruby!
1. (Optional) If you are on the same server, uninstall the MRI Ruby:
yum -y remove ruby\*
2. Install Jruby (this assumes that you have installed my repository)
yum -y install jruby
3. Install the sinatra and puma gems for Jruby:
jruby -S gem install sinatra puma --no-ri --no-rdoc
4. Run Puma:
jruby sinatra-puma.rb -s Puma -p 80 -o 0.0.0.0