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.