# Configuring eruby with apache

**URL:** <https://www.ruby-forum.com/t/configuring-eruby-with-apache/98499>\
**Category:** Ruby\
**Created:** [July 15, 2006, 2:02am UTC](https://www.ruby-forum.com/t/configuring-eruby-with-apache/98499 "2006-07-15T02:02:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 15, 2006, 2:02am UTC](https://www.ruby-forum.com/t/configuring-eruby-with-apache/98499/1 "2006-07-15T02:02:16Z")

</div>

Hi everybody!

Sorry if this not the right place to post, please tell me where I  
should ask such a question if it’s not the right place to post here.

I just would like to enable .rhtml files to be automatically converted  
by eruby using apache2, but I didn’t managed to do it so far.  
How did you succeed in doing so?  
I use Ubuntu 6.06, with  
eruby 1.0.5-1  
libapache2-mod-ruby 1.2.5-1  
ruby1.8.4  
apache2 2.0.55

Any success story corresponding to my configuration?

Thanks for your attention,

Eric.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 15, 2006, 2:11am UTC](https://www.ruby-forum.com/t/configuring-eruby-with-apache/98499/2 "2006-07-15T02:11:42Z")

</div>

Eric DUMINIL wrote:

> libapache2-mod-ruby 1.2.5-1  
> ruby1.8.4  
> apache2 2.0.55
> 
> Any success story corresponding to my configuration?
> 
> Thanks for your attention,
> 
> Eric.

Have you set up your httpd2.conf file?

First, there has to be this up with the other modules:

LoadModule ruby\_module /usr/lib/apache2/mod\_ruby.so

Then, below, there is something like:

#lots of other stuff here  
#just showing the stuff for .rhtml files

# # for Apache::ERubyRun

RubyRequire apache/eruby-run

# handle \*.rhtml as eruby files.

\<Files \*.rhtml\>  
SetHandler ruby-object  
RubyHandler Apache::ERubyRun.instance

Does that help?

-Justin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 15, 2006, 5:41am UTC](https://www.ruby-forum.com/t/configuring-eruby-with-apache/98499/3 "2006-07-15T05:41:01Z")

</div>

On Jul 14, 2006, at 8:09 PM, Justin C. wrote:

> Then, below, there is something like:  
> SetHandler ruby-object  
> RubyHandler Apache::ERubyRun.instance
> 
> Does that help?
> 
> -Justin

Also, if you get that running, I really like that you can plunk this  
into a .htaccess file and get exception traces:

\<Files \*.rhtml\>  
SetHandler ruby-object  
RubyHandler Apache::ERubyDebug.instance

Yay simplicity. Now if only dealing with headers/cookies and the  
like were easier from within Apache/eRuby…  
-Mat

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 15, 2006, 12:07pm UTC](https://www.ruby-forum.com/t/configuring-eruby-with-apache/98499/4 "2006-07-15T12:07:50Z")

</div>

Thanks a lot for your reply Justin!  
(and thank you too Mat, but I cannot try your tip yet)

So, I tried to modify http.conf by adding:

###########################################################  
LoadModule ruby\_module /usr/lib/apache2/modules/mod\_ruby.so

# # for Apache::ERubyRun

RubyRequire apache/eruby-run

# handle \*.rhtml as eruby files.

\<Files \*.rhtml\>  
SetHandler ruby-object  
RubyHandler Apache::ERubyRun.instance  
  
  
###########################################################

And then,

$ sudo /etc/init.d/apache2 force-reload

- Forcing reload of apache 2.0 web server…  
[Fri Jul 14 18:36:45 2006] [warn] module ruby\_module is already loaded,  
skipping  
[Fri Jul 14 18:36:47 2006] [warn] module ruby\_module is already loaded,  
skipping  
[ok]

Indeed, I already enabled ruby\_module by using  
$ a2enmod ruby

So I removed the link “/etc/apache2/mods-enabled/ruby”  
and reloaded apache2, without warning this time.

But now, when I try to view a .rhtml file, my browser only asks me if I  
want  
to download this file or open it with a text editor. :-/

Thanks again for your help,

Eric

Am Samstag, 15. Juli 2006 02:09 schrieb Justin C.:

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 15, 2006, 1:27pm UTC](https://www.ruby-forum.com/t/configuring-eruby-with-apache/98499/5 "2006-07-15T13:27:51Z")

</div>

Ok!

I found the solution 🙂

I removed

# # for Apache::ERubyRun

RubyRequire apache/eruby-run  
# handle \*.rhtml as eruby files.  
\<Files \*.rhtml\>  
SetHandler ruby-object  
RubyHandler Apache::ERubyRun.instance

from httpd.conf  
and replaced it with:

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

Then  
sudo a2enmod ruby actions  
made the rest.

Thanks for your help!

Eric

PS : any clue why my posts are always doubled???

Am Samstag, 15. Juli 2006 12:05 schrieb Éric DUMINIL:

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 15, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/configuring-eruby-with-apache/98499/6 "2006-07-15T21:47:33Z")

</div>

Éric DUMINIL wrote:

> Ok!
> 
> I found the solution 🙂

Glad you got it working, I’m not an expert on it or anything 🙂

> Thanks for your help!
> 
> Eric
> 
> PS : any clue why my posts are always doubled???

They aren’t really doubled, they just look that way in gmail.

-Justin
