How to install mod_ruby and eruby on Linux server ?
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



















hi there, thanks for the tutorial. However im having this error message when i try to install mod_ruby. My apache install directory is /opt/lampp
checking for a BSD compatible install… /usr/bin/install -c
checking whether we are using gcc… yes
checking Ruby version… 1.8.6
checking for static Apache module support… no
checking for dynamic Apache module support… ./configure.rb:65: command not found: apxs -q INCLUDEDIR
./configure.rb:65: command not found: apxs -q LIBEXECDIR
please advise. Thanks
It seems that apxs path is wrong in your “# ./configure.rb –enable-eruby –with-apxs=/usr/local/apache/bin/apxs” command , Please enter the correct path and run above command again.
Regards
AlexP
I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.
Where exactly should I copy the following code in the httpd.conf file?
“start Code”
LoadModule ruby_module libexec/mod_ruby.so
ClearModuleList
AddModule mod_ruby.c
AddHandler cgi-script .rb
# for Ruby/eRuby
# 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.
SetHandler ruby-object
RubyHandler Apache::RubyRun.instance
# handle *.rhtml as eruby files.
SetHandler ruby-object
RubyHandler Apache::ERubyRun.instance
“End Code”
I put in several lines and reset the apache error fails.
Thanks
@Avel
May I know what exact error do you getting ?
Regards
Alex P