Apache2 + eruby problem

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 webmaster@site.local
  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/
  <Location />
    Options +ExecCGI
  </Location>
  ErrorLog /var/www/site/logs/error.log
  CustomLog /var/www/site/logs/access.log combined
</VirtualHost>

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:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>eruby test</title>
</head>
<body>
<center>
<h1>eruby test</h1>
<p>
<% print "hello world" %>
</p>
</center>
</body>
</html>

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

thanks,
Sam

Try searching the archive for eruby apache :wink: 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 is a howto for windows.

···

On 12/20/06, Sam Waller <sam.waller@avmet.com> wrote:

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 webmaster@site.local
        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/
        <Location />
                Options +ExecCGI
        </Location>
        ErrorLog /var/www/site/logs/error.log
        CustomLog /var/www/site/logs/access.log combined
</VirtualHost>

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:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>eruby test</title>
</head>
<body>
<center>
<h1>eruby test</h1>
<p>
<% print "hello world" %>
</p>
</center>
</body>
</html>

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

thanks,
Sam

Try searching the archive for eruby apache :wink: 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 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

>
>Try searching the archive for eruby apache :wink: 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 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 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)

···

On 12/21/06, Sam Waller <sam.waller@avmet.com> wrote:

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