Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

Ruby Programming
Previous Page Home Next Page

Installing eruby in Apache

You can set up an Apache Web server to automatically parse Ruby-embedded documents using eRuby, much in the same way that PHP does. You create Ruby-embedded files with an ``.rhtml'' suffix and configure the Web server to run the eruby executable on these documents to produce the desired HTML output.

In order to use eruby with the Apache Web server, you need to perform the following steps.

  • Copy the eruby binary to the cgi-bin directory.

  • Add the following two lines to httpd.conf:

    AddType application/x-httpd-eruby .rhtml
    Action application/x-httpd-eruby /cgi-bin/eruby
    

  • If desired, you can also add or replace the DirectoryIndex directive such that it includes index.rhtml. This lets you use Ruby to create directory listings for directories that do not contain an index.html. For instance, the following directive would cause the embedded Ruby script index.rhtml to be searched for and served if neither index.html nor index.shtml existed in a directory.

    DirectoryIndex index.html index.shtml index.rhtml
    

    Of course, you could also simply use a site-wide Ruby script as well.

    DirectoryIndex index.html index.shtml /cgi-bin/index.rb
    

And that's it! You can now write HTML documents that contain embedded Ruby to generate forms and content dynamically. Be sure to see also the Ruby CGI library, which is documented beginning on page 497.
Ruby Programming
Previous Page Home Next Page

 
 
  Published under the terms of the Open Publication License Design by Interspire