apache2 + eruby problem

S

Sam Waller

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 (e-mail address removed)
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
 
J

Jan Svitok

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 (e-mail address removed)
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 ;-) 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.
 
S

Sam Waller

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 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
 
J

Jan Svitok

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.

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top