# Apache2 + eruby problem

**URL:** <https://www.ruby-forum.com/t/apache2-eruby-problem/79950>\
**Category:** Ruby\
**Created:** [December 20, 2006, 7:10pm UTC](https://www.ruby-forum.com/t/apache2-eruby-problem/79950 "2006-12-20T19:10:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [December 20, 2006, 7:10pm UTC](https://www.ruby-forum.com/t/apache2-eruby-problem/79950/1 "2006-12-20T19:10:14Z")

</div>

I can get Apache2 on Ubuntu Edgy to execute ruby (.rb) files. But I’m  
having  
trouble getting it to recognize .rhtml files. Here is the  
sites-available file.

/etc/apache2/sites-available/www.site.local:

\<VirtualHost \*\>  
ServerAdmin removed\_email\_address@domain.invalid  
ServerName www.site.local  
ServerAlias site.local  
AddHandler cgi-script .rb  
AddType application/x-httpd-eruby .rhtml  
DirectoryIndex index.php  
DocumentRoot /var/www/site  
ScriptAlias /cgi-bin/ /var/www/site/  
  
Options +ExecCGI  
  
ErrorLog /var/www/site/logs/error.log  
CustomLog /var/www/site/logs/access.log combined

I installed eruby and have /usr/sbin/eruby in my path. I’m trying to get  
a  
ruby hit counter embedded in html format files, so I think that I’d need  
eruby to do that. If I try opening test.rhtml the browser wants to open  
it  
as text or download it. Here is test.rhtml:

eruby test
# eruby test

\<% print "hello world" %\>

Can someone explain how to get .rhtml files working with Apache2?

thanks,  
Sam

---

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [December 20, 2006, 7:14pm UTC](https://www.ruby-forum.com/t/apache2-eruby-problem/79950/2 "2006-12-20T19:14:24Z")

</div>

On 12/20/06, Sam W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> AddHandler cgi-script .rb
> 
> ```
> 
> thanks,  
> Sam

Try searching the archive for eruby apache 😉 For me, it found ~13  
threads (not of them useful, though)

Most probably you’ll need to set the mime type and handler for rhtml

[http://www.hiveminds.co.uk/node/3094](http://www.hiveminds.co.uk/node/3094) is a howto for windows.

---

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [December 21, 2006, 5:06pm UTC](https://www.ruby-forum.com/t/apache2-eruby-problem/79950/3 "2006-12-21T17:06:41Z")

</div>

On 12/21/06, Sam W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Try searching the archive for eruby apache 😉 For me, it found ~13  
> > threads (not of them useful, though)
> > 
> > Most probably you’ll need to set the mime type and handler for rhtml
> > 
> > [http://www.hiveminds.co.uk/node/3094](http://www.hiveminds.co.uk/node/3094) is a howto for windows.
> 
> I’ve done that, but can’t get it to work. Many of these links say add an ‘Action’ line to httpd.conf  
> but I think that you are not supposed to touch httpd.conf in apache2. I tried adding this line to

at the very and there is a line include /etc/…/\* that includes  
anything from i-dont-remember-its-name directory found in the  
/etc/apache2 So just create a new file, or edit the ‘default’ file  
which is the default server’s configuration.

> /etc/apache2/apache2.conf but I get this when I try to reload apache2:

> $ /etc/init.d/apache2 reload
> 
> - Reloading apache 2.0 configuration… Syntax error on line  
> 343 of /etc/apache2/apache2.conf:  
> Invalid command ‘Action’, perhaps mis-spelled or defined by a module not included in the server  
> configuration.

[mod\_actions - Apache HTTP Server Version 2.2](http://httpd.apache.org/docs/2.2/mod/mod_actions.html#action) says you  
need to have the mod\_actions module enabled. you can enable it by  
symlinking from /etc/apache2/mods.available to /etc/…/mods.enabled  
(or something similar, it’s pretty obvious, you’ll figure it out  
yourself)

---

<div class="post-metadata">

**Author:** ![sweb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@sweb](https://www.ruby-forum.com/u/sweb)\
**Post date:** [December 21, 2006, 9:51am UTC](https://www.ruby-forum.com/t/apache2-eruby-problem/79950/4 "2006-12-21T09:51:44Z")

</div>

> Try searching the archive for eruby apache 😉 For me, it found ~13  
> threads (not of them useful, though)
> 
> Most probably you’ll need to set the mime type and handler for rhtml
> 
> [http://www.hiveminds.co.uk/node/3094](http://www.hiveminds.co.uk/node/3094) is a howto for windows.

I’ve done that, but can’t get it to work. Many of these links say add an  
‘Action’ line to httpd.conf  
but I think that you are not supposed to touch httpd.conf in apache2. I  
tried adding this line to  
/etc/apache2/apache2.conf but I get this when I try to reload apache2:

$ /etc/init.d/apache2 reload

- Reloading apache 2.0 configuration…  
Syntax error on line  
343 of /etc/apache2/apache2.conf:  
Invalid command ‘Action’, perhaps mis-spelled or defined by a module not  
included in the server  
configuration.

Eg, the above howto says:

1. in httpd.conf add:  
AddType application/x-httpd-eruby .rhtml

#use your own path to eruby  
Action application/x-httpd-eruby “e:/usr/local/bin/eruby.exe”

(I used /usr/bin/eruby)

I’m using Ubuntu edgy linux. Does anyone know how to get eruby working  
with this OS?

thanks,  
Sam
