How to install mod_ruby and eruby on Linux server ?
April 8th, 2009
5 comments
What is mod_ruby?
mod_ruby embeds the Ruby interpreter into the Apache web server, allowing Ruby CGI scripts to be executed natively. These scripts will start up much faster than without mod_ruby.
1) Install eRuby
# wget http://www.modruby.net/archive/eruby-1.0.5.tar.gz
# tar -xzvf eruby-1.0.5.tar.gz
# cd eruby-1.0.5/
# ./configure.rb –with-charset=euc-jp –enable-shared
# make; make install
2) Install mod_ruby
i)Download latest mod_ruby tar file
# wget http://www.modruby.net/archive/mod_ruby-1.2.6.tar.gz
# tar -xzvf mod_ruby-1.2.6.tar.gz
# cd mod_ruby-1.2.6/
# ./configure.rb –enable-eruby –with-apxs=/usr/local/apache/bin/apxs
# make; make install
ii)Edit apache configuration file ( httd.conf) and add following code
LoadModule ruby_module libexec/mod_ruby.so ClearModuleList AddModule mod_ruby.c AddHandler cgi-script .rb <IfModule mod_mime.c> # for Ruby/eRuby <IfModule mod_ruby.c> # for Apache::RubyRun RubyRequire apache/ruby-run # for Apache::ERubyRun RubyRequire apache/eruby-run # for development # RubyRequire auto-reload # for add library #RubyAddPath /usr/local/lib/ruby # exec *.rbx as ruby scripts. <Files *.rbx> SetHandler ruby-object RubyHandler Apache::RubyRun.instance </Files> # handle *.rhtml as eruby files. <Files *.rhtml> SetHandler ruby-object RubyHandler Apache::ERubyRun.instance </Files> </IfModule> </IfModule>
iii) Restart apache service on server
Regards
Alex P

