Home > Cpanel Server, Dedicated Server > How to install mod_ruby and eruby on Linux server ?

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

  1. whan bio
    April 30th, 2009 at 11:33 | #1

    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

  2. April 30th, 2009 at 14:21 | #2

    checking for dynamic Apache module support… ./configure.rb:65: command not found: apxs -q INCLUDEDIR
    ./configure.rb:65: command not found: apxs -q LIBEXECDIR

    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

  3. make windows xp run faster
    July 20th, 2009 at 18:37 | #3

    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.

  4. Avel
    August 11th, 2009 at 04:51 | #4

    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

  5. September 21st, 2009 at 02:39 | #5

    @Avel
    May I know what exact error do you getting ?
    Regards
    Alex P

  1. April 4th, 2010 at 09:32 | #1