Install mod_ruby and eruby in Apache

Source: Internet
Author: User
1. Introduction
Mod_ruby is embedded with the Ruby interpreter in Apache to facilitate Ruby CGI execution.
: Http://modruby.net/archive/mod_ruby-1.2.4.tar.gz
Eruby is the implementation of eruby, which embeds Ruby code into common text, such as HTML, so as to be similar to ASP and PHP.
: Http://modruby.net/archive/eruby-1.0.5.tar.gz

2. Installation
Install Apache: (1.3.29)

./Configure -- prefix =/usr/local/Apache -- enable-module = rewrite -- enable-module = so
Make
Make install

Install mod_ruby:
CD mod_ruby-1.2.4
./Configure. RB -- With-apxs =/usr/local/Apache/bin/apxs
Make
Make install

Install eruby
CD eruby-1.0.5
./Configure. Rb
Make
Make install

3. Configuration

Edit/usr/local/Apache/CONF/httpd. conf
 
Add the following content:

Loadmodule ruby_module/usr/local/Apache/libexec/mod_ruby.so

# Clearmodulelist
# Addmodule mod_ruby.c

<Ifmodule mod_ruby.c>
Rubyrequire Apache/ruby-run

# Excucute files under/Ruby as Ruby scripts
<Location/usr/local/Apache/htdocs>
Sethandler ruby-Object
Rubyhandler Apache: rubyrun. Instance
Options + execcgi
</Location>

# Execute *. RB files as Ruby scripts
<Files *. rb>
Sethandler ruby-Object
Rubyhandler Apache: rubyrun. Instance
</Files>

</Ifmodule>
<Ifmodule mod_ruby.c>
Rubyrequire Apache/eruby-run

# Handle files under/eruby as eruby files
<Location/usr/local/Apache/htdocs>
Sethandler ruby-Object
Rubyhandler Apache: erubyrun. Instance
</Location>

# Handle *. rhtml files as eruby files
<Files *. rhtml>
Sethandler ruby-Object
Rubyhandler Apache: erubyrun. Instance
</Files>
</Ifmodule>

Create a file test. rhtml under the Web root directory,
Content:
Hello <% = "world" %>

Open/test. rhtml in the browser. If everything is normal, the following error occurs: Hello world.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.