Knowledgebase: 3rd Party Software
Get Started with eRuby
Posted by on 10 August 2012 11:56 AM

Set Up Your cgi-bin Folder

You need to add an 'eruby' script to your '~/public_html/cgi-bin' folder. Here's what it should look like:

#!/bin/bash
echo "Content-type: text/html"
echo
echo "<!DOCTYPE HTML>"
​erubis -E Stdout <$DOCUMENT_ROOT$REQUEST_URI
 

Save the above file as '~/public_html/cgi-bin/eruby' and change its permissions to be executable.

Set Up Your .htaccess File

Finally, you'll need to create an .htaccess file in your '~/public_html/' folder and add the following three lines:

​Action eruby-script /cgi-bin/eruby
AddHandler eruby-script .rhtml
DirectoryIndex index.html index.rhtml


This will cause any *.rhtml files to load the eRuby script that we just set up, and that file will send the 'rhtml' file through the eRuby parser before displaying it to the user.

Set Up a Rewrite Rule

*This is an optional step.

If you don't like having a 'rhtml' hanging off the end of your URLs, you can add this to the .htaccess file as well:


RewriteEngine on
RewriteRule ^(.*)(?<!\.rhtml)$ $1.rhtml [L] 
 

Now you can upload files ending in '.rhtml' that contain Ruby code enclosed in <% %> or <%= %> markers and have the contents run as Ruby:

<html> 
<body>
1 and 2 is 
<% puts 1 + 2 %>
</body> 
</html>


If you are receiving a 404 (not found) error after setting this up you may need cgi privileges enabled on your account. You can open a support ticket and we will be happy to enable this for you.

(1 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion
ERROR: This domain name (kb.asmallorange.com), does not match the domain name in the license key file help.asmallorange.com.

For assistance with your license, please contact the Kayako support team: https://support.kayako.com