500 internal error on apache

C

coke

I came across Ruby about 33 hours and decided to take it up.I have
exp. with apache,php and such but no cgi,perl or anything close to
ruby.I've configured my apache(ver. 1.3.31) for ruby.When I type the
address of the .rb file into my broswer I get an 500 Internal error,I
have no clue and can't find anything on it.

Specs:
Windows 98
Apache 1.3.31
Ruby 1.8
 
H

Hugh Sasse Staff Elec Eng

I came across Ruby about 33 hours and decided to take it up.I have
exp. with apache,php and such but no cgi,perl or anything close to
ruby.I've configured my apache(ver. 1.3.31) for ruby.When I type the

I think you'll need to tell us what you did to achieve that. There
ae a number of ways of using Ruby with Apache, for one thing.
address of the .rb file into my broswer I get an 500 Internal error,I

and can you tell us what is in the file?
have no clue and can't find anything on it.

Specs:
Windows 98
Apache 1.3.31
Ruby 1.8

Hugh
 
N

Neil Stevens

I came across Ruby about 33 hours and decided to take it up.I have
exp. with apache,php and such but no cgi,perl or anything close to
ruby.I've configured my apache(ver. 1.3.31) for ruby.When I type the
address of the .rb file into my broswer I get an 500 Internal error,I
have no clue and can't find anything on it.

Specs:
Windows 98
Apache 1.3.31
Ruby 1.8

Check your Apache error log after seeing the 500 error to see what's wrong
with the ruby you're attempting to run.
 
C

coke

I'm very new to cgi and have no background of programming other than a
little php editing and that's it.After seeing hugh's message I went
back to the test script and looked for typos and surly there was one.I
corrected the typo and everything worked fine,thanks for the replys.
 
P

Patrick Gundlach

coke said:
I'm very new to cgi and have no background of programming other than a
little php editing and that's it.After seeing hugh's message I went
back to the test script and looked for typos and surly there was one.I
corrected the typo and everything worked fine,thanks for the replys.

You also might find prettyexception useful. I think it is a great tool
for web development/debugging.

http://muravey-tools.rubyforge.org/

Patrick
 
N

Nicholas Van Weerdenburg

Since you mention being new to cgi, and have doning some php, I'm
guessing you aren't using the ruby script in the right directory, or
using the right url to call it, or are missing some boilerplate.

Ruby and php are not directly equivalent. If you've only installed
ruby, you need to put the ruby script into your cgi-bin directory,
since cgi is how you would call it.

e.g.
http://localhost/cgi-bin/test.rb

would be the right url for a file in the apache cgi-bin directory.

Also, you may need to put some http boilerplate.
test.rb
======
#!/usr/local/bin/ruby
print "Content-type: text/html\r\n\r\n"
print "hello"

On Apache on OS X, I need the second line for it to work. The first line
is Unix specific, and won't apply to Windows.

There is also a cgi module to help with many common cgi tasks that you
can look at.

If you want to use ruby in the same way as Php, you need to install
mod_ruby and eruby:
http://www.modruby.net/en/

Then you can create files like index.rhtml, and use embedded ruby code,
much like how php works. This may be your best starting point if you
like the php method.

Or install a web framework like rails, iowa, arrow, etc, and follow
their conventions.

Regards,
Nick
 
C

coke

Very helpfull, thanks

Since you mention being new to cgi, and have doning some php, I'm
guessing you aren't using the ruby script in the right directory, or
using the right url to call it, or are missing some boilerplate.

Ruby and php are not directly equivalent. If you've only installed
ruby, you need to put the ruby script into your cgi-bin directory,
since cgi is how you would call it.

e.g.
http://localhost/cgi-bin/test.rb

would be the right url for a file in the apache cgi-bin directory.

Also, you may need to put some http boilerplate.
test.rb
======
#!/usr/local/bin/ruby
print "Content-type: text/html\r\n\r\n"
print "hello"

On Apache on OS X, I need the second line for it to work. The first line
is Unix specific, and won't apply to Windows.

There is also a cgi module to help with many common cgi tasks that you
can look at.

If you want to use ruby in the same way as Php, you need to install
mod_ruby and eruby:
http://www.modruby.net/en/

Then you can create files like index.rhtml, and use embedded ruby code,
much like how php works. This may be your best starting point if you
like the php method.

Or install a web framework like rails, iowa, arrow, etc, and follow
their conventions.

Regards,
Nick
 
N

Nicholas Van Weerdenburg

Glad to help.

I'd recommend checking out #ruby-lang and #rubyonrails IRC groups. Great
for immediate feedback/help.

Nick
 

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,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top