Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > apache2 + ubuntu edgy + ruby

Reply
Thread Tools

apache2 + ubuntu edgy + ruby

 
 
Sam Waller
Guest
Posts: n/a
 
      12-08-2006

I'm running Ubuntu edgy linux, apache2, php5, and ruby 1.8.4

I've been able to get apache2 to run php scripts easily but am having
problems getting ruby to do so. I've read references to eruby,
libapache2-mod-ruby, fastcgi etc, etc. So, I'm not sure what I really
need. I did install Ubuntu's libapache2-mod-ruby and I now see
/etc/apache2/mods-enabled/ruby.load -> /etc/apache2/mods-available/ruby.load.
I also found a /usr/lib/apache2/modules/mod_ruby.so.

I've tried many variations in the site .conf file in
/etc/apache2/sites-available/www.site.local. What I currently have in
this file is:

<VirtualHost *>
ServerAdmin http://www.velocityreviews.com/forums/(E-Mail Removed)
ServerName www.site.local
ServerAlias site.local

AddHandler cgi-script .rb

DirectoryIndex index.php
DocumentRoot /var/www/site

# CGI Directory
ScriptAlias /cgi-bin/ /var/www/site/
<Location />
Options +ExecCGI
</Location>

# Logfiles
ErrorLog /var/www/site/logs/error.log
CustomLog /var/www/site/logs/access.log combined
</VirtualHost>

Since php is working here is what I have added to /etc/apache2/apache2.conf:

AddType application/x-httpd-php .php
AddType application/x-httpd-php .html

I'm only trying to get apache2 to run ruby programs (.rb files) like it
does .php files. Can someone tell me what is needed to make this work?

When I try to run a test.rb file I'm getting this in the error.log file:

[Fri Dec 08 13:52:30 2006] [error] [client 127.0.0.1] (2)\xd9\x05i\xb7: exec of
'/var/www/site/test.rb' failed
[Fri Dec 08 13:52:30 2006] [error] [client 127.0.0.1] Premature end of script headers: test.rb

and the browser shows:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to
complete your request.

Please contact the server administrator, (E-Mail Removed) and inform them
of the time the error occurred, and anything you might have done that may have
caused the error.

More information about this error may be available in the server error log.

test.rb just contains this:

#!/usr/bin/ruby
print "Content-type: text/html\r\n\r\n"
print "<html><body>Hello World!</body></html>\r\n"

thanks,

Sam



 
Reply With Quote
 
 
 
 
Grant Hollingworth
Guest
Posts: n/a
 
      12-08-2006
* Sam Waller <(E-Mail Removed)> [2006-12-08 12:00]:
>When I try to run a test.rb file I'm getting this in the error.log file:
>
>[Fri Dec 08 13:52:30 2006] [error] [client 127.0.0.1] (2)\xd9\x05i\xb7: exec of
>'/var/www/site/test.rb' failed
>[Fri Dec 08 13:52:30 2006] [error] [client 127.0.0.1] Premature end of script headers: test.rb


It might be a problem with suexec. Check suexec.log. You probably have to change the permissions on the script -- suexec doesn't like scripts (or the directories they're in) to be group-writable.

 
Reply With Quote
 
 
 
 
Sam Waller
Guest
Posts: n/a
 
      12-09-2006
On Sat, 9 Dec 2006 06:44:27 +0900, Grant Hollingworth <(E-Mail Removed)> wrote:

>* Sam Waller <(E-Mail Removed)> [2006-12-08 12:00]:
>>When I try to run a test.rb file I'm getting this in the error.log file:
>>
>>[Fri Dec 08 13:52:30 2006] [error] [client 127.0.0.1] (2)\xd9\x05i\xb7: exec of
>>'/var/www/site/test.rb' failed
>>[Fri Dec 08 13:52:30 2006] [error] [client 127.0.0.1] Premature end of script headers: test.rb

>
>It might be a problem with suexec. Check suexec.log. You probably have to change the permissions on the script -- suexec doesn't like scripts (or the directories they're in) to be group-writable.


'which ruby' say
/usr/bin/ruby

the permissions and ownership of test.rb:
-rwxr-xr-x 1 www-data www-data 110 2006-12-08 12:37 test.rb*

the directory that test.rb was in: /var/www/site was owned by root and I changed it to
www-data:www-data and I get the same error.


I tried changing test.rb to the following but still get the same error and couldn't find additional
information:

require 'net/http'
http = Net::HTTP.new('localhost', 80)
resp, page = http.get('/var/www/site', nil )

I also tried removing the space as mentioned but get the same results.

I also have run into problems with carriage returns and linefeeds in scripts so I dumped test.rb
just to be sure:

00000000 23 21 2f 75 73 72 2f 62 69 6e 2f 72 75 62 79 0d |#!/usr/bin/ruby.|
00000010 0a 70 72 69 6e 74 20 22 43 6f 6e 74 65 6e 74 2d |.print "Content-|
00000020 74 79 70 65 3a 74 65 78 74 2f 68 74 6d 6c 5c 72 |type:text/html\r|
00000030 5c 6e 5c 72 5c 6e 22 0d 0a 70 72 69 6e 74 20 22 |\n\r\n"..print "|
00000040 3c 68 74 6d 6c 3e 3c 62 6f 64 79 3e 48 65 6c 6c |<html><body>Hell|
00000050 6f 20 57 6f 72 6c 64 21 3c 2f 62 6f 64 79 3e 3c |o World!</body><|
00000060 2f 68 74 6d 6c 3e 5c 72 5c 6e 22 0d 0a |/html>\r\n"..|
0000006d

Thanks for your help,
Sam

 
Reply With Quote
 
Sam Waller
Guest
Posts: n/a
 
      12-09-2006
On Sat, 09 Dec 2006 12:15:37 GMT, Steven J Masta <(E-Mail Removed)> wrote:

>Sam Waller wrote:
>
><snip>
>
>> When I try to run a test.rb file I'm getting this in the error.log file:
>>
>> [Fri Dec 08 13:52:30 2006] [error] [client 127.0.0.1] (2)\xd9\x05i\xb7: exec of
>> '/var/www/site/test.rb' failed
>> [Fri Dec 08 13:52:30 2006] [error] [client 127.0.0.1] Premature end of script headers: test.rb

>
>You'll get that if you have DOS style (CRLF) line endings in your
>script. Convert to Unix (LF) and see if that fixes it.
>
>Steve


That was the problem: I needed to get rid of the carriange returns (0x0d). I used the 'fromdos' in
Ubuntu's packages. Thanks.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get Apache2 tp process py (Ubuntu 11.10) Passiday Python 1 12-15-2011 11:20 PM
tomcat configuration broken after upgrade from ubuntu edgy to feisty Amir Michail Java 3 04-25-2007 12:01 AM
Dapper to Edgy Dave Doe NZ Computing 29 10-30-2006 09:52 PM
Updating to Ubuntu Edgy beta Philip NZ Computing 4 10-23-2006 12:48 AM



Advertisments