[ start | index | login ]
start > knowledgebase > linux > Setup eRuby

Setup eRuby

Created by john. Last edited by john, 2 years and 359 days ago. Viewed 2,524 times. #1
[edit] [rdf]
labels
attachments
If you would like to use embedded Ruby with Apache, so that you can embed ruby code into your html documents, here is a quick way to configure it.

If you are going to use eRuby with a virtual host you will need to enable cgi programs.

On Debian based distros the default cgi-bin is here, but you may need to insert this into your virtual host directive

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

On RedHat/Fedora based distros it looks like this

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

Then copy this script into a file called eruby.sh or similar.

#!/bin/bash
apt-get install -y eruby

if [ -e /etc/redhat-release ]; then touch /etc/httpd/conf.d/eruby.conf echo "Action application/x-httpd-eruby /cgi-bin/eruby" > /etc/httpd/conf.d/eruby.conf fi

if [ -e /etc/debian-release ]; then touch /etc/apache2/conf.d/eruby.conf echo "Action application/x-httpd-eruby /cgi-bin/eruby" > /etc/apache2/conf.d/eruby.conf fi

echo "application/x-httpd-eruby rhtml" >> /etc/mime.types

if [ -e /etc/debian-release ]; then ln -s $(which eruby) /usr/lib/cgi-bin/eruby a2enmod actions /etc/init.d/apache2 restart echo '<% puts "Hello World!" %>' > /var/www/test.rhtml fi

# afaik the actions module is enabled on fedora if [ -e /etc/redhat-release ]; then ln -s $(which eruby) /var/www/cgi-bin/eruby echo '<% puts "Hello World!" %>' > /var/www/html/test.rhtml fi

# Restart Apache

if [ -e /etc/debian-release ]; then /etc/init.d/apache2 restart fi

if [ -e /etc/redhat-release ]; then /etc/init.d/httpd restart fi

Now browse to >>http://yourdomain/test.rhtml and see that it works.

This will allow you to experiment with inline Ruby programing in your html pages, but if your seriously looking to use eruby you might want to consider using mod_ruby, more information here:

>>http://wiki.modruby.net/en/?InstallGuide

This script was suggested by what I read on this page:

>>http://www.rubycentral.com/book/web.html

no comments | post comment
Powered by snipsnap.org Found a mistake in a howto? Let us know via an email to p.blikibugs at rimuhosting com.