# rbTenjin + Apache?

**URL:** <https://www.ruby-forum.com/t/rbtenjin-apache/114586>\
**Category:** Ruby\
**Created:** [September 16, 2007, 3:31pm UTC](https://www.ruby-forum.com/t/rbtenjin-apache/114586 "2007-09-16T15:31:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [September 16, 2007, 3:31pm UTC](https://www.ruby-forum.com/t/rbtenjin-apache/114586/1 "2007-09-16T15:31:50Z")

</div>

Hi,

[http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#intro](http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#intro)

looks nice. Does someone know how to set it up with Apache?  
(Both are already installed and work on my linux box here)

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/rbtenjin-apache/114586/2 "2007-09-17T13:24:15Z")

</div>

Quoth Marc H.:

> Hi,
> 
> [http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#intro](http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#intro)
> 
> looks nice. Does someone know how to set it up with Apache?  
> (Both are already installed and work on my linux box here)

Looks like a cross between erb (google it) and PHP (ugh). Have you seen  
Markaby / RedCloth etc? There are many nicer and more ruby-esque tools  
out  
there.

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 24, 2008, 1:10pm UTC](https://www.ruby-forum.com/t/rbtenjin-apache/114586/3 "2008-02-24T13:10:23Z")

</div>

This is how I did it, I am not an Apache guru so please correct me  
anybody if this is a bad way to do it:

For Ubuntu 7.10 and assuming you already have mod\_ruby and ruby gems  
installed:

1. Install tenjin

gem install tenjin

1. Make make a file named ruby.conf under /etc/apache2/conf.d

## Add the following into ruby.conf

AddType text/html .rbx

RubyRequire apache/ruby-run

\<Files \*.rbx\>  
Options ExecCGI  
SetHandler ruby-object  
RubyHandler Apache::RubyRun.instance

----------------------------------------
1. Go into /usr/lib/ruby/1.8/apache/ruby-run.rb

## Add the following under where it says ‘require “singleton”’

## require “singleton” require “rubygems” require “tenjin”

1. Test it out:

## Go to your Apache Document Root where you serve your files. Create a file named main.rbx and enter the following:

engine = Tenjin::Engine.new()

## context = {:title=\>‘Hello World’} filename = ‘file.rbhtml’ output = engine.render(filename, context) puts output

## Create a template named file.rbhtml and include the following

# #{@title}
------------------------------------------------

Goto your browser and type in: YOURDOMAIN/main.rbx

Your browser should then display “Hello World”.

Marc H. wrote:

> Hi,
> 
> [http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#intro](http://www.kuwata-lab.com/tenjin/rbtenjin-users-guide.html#intro)
> 
> looks nice. Does someone know how to set it up with Apache?  
> (Both are already installed and work on my linux box here)

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 25, 2008, 6:39am UTC](https://www.ruby-forum.com/t/rbtenjin-apache/114586/4 "2008-02-25T06:39:39Z")

</div>

Hi there,

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![quik77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/dec6dc/32.png) [@quik77](https://www.ruby-forum.com/u/quik77)\
**Post date:** [February 25, 2008, 7:08am UTC](https://www.ruby-forum.com/t/rbtenjin-apache/114586/5 "2008-02-25T07:08:09Z")

</div>

Marc H. wrote:

> Hi there,
> 
> Thanks for the help!

I forgot to mention, you will need to have write permissions on the  
directory where your template (e.g. file.rbhtml) is placed in. This is  
because tenjin creates a .cache version of your .rbhtml in the same  
directory, thus if you do not have write permissions, it will not work.
