Jump to content

Apache AddHandler Problems


hawleyal

Recommended Posts

Problem

 

I cannot seem to be able to add the cgi-script handler for ruby scripts (.rb).

 

I can run perl, python, and ruby scripts using the .cgi extension.

 

I can run perl (.pl) and python (.py) scripts without adding any handlers.

 

Interestingly, I can run perl scripts using any file extension without adding any handlers.

 

I cannot run python or ruby scripts using any other extensions, even if I add handlers.

 

 

Handler Examples

 

I've tried adding it to the cPanel / Apache Handlers:

handler: cgi-script

extensions: .rb

 

I've also tried adding it to the .htaccess file:

http://alexanderhawley.com/cgi-bin/.htaccess

AddHandler cgi-script .rb

 

 

Perl Examples

 

Perl works with extensions .cgi, .pl.

No additional handlers needed.

 

http://alexanderhawley.com/cgi-bin/testperl.cgi

#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "perl";

 

http://alexanderhawley.com/cgi-bin/testperl.pl

#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "perl";

 

 

Python Examples

 

Python works with extensions .cgi, .py.

No additional handlers needed.

 

http://alexanderhawley.com/cgi-bin/testpython.cgi

#!/usr/bin/python
print "Content-Type: text/plain\n\n"
print "python"

 

http://alexanderhawley.com/cgi-bin/testpython.py

#!/usr/bin/python
print "Content-Type: text/plain\n\n"
print "python"

 

 

Ruby Examples

 

Ruby only works with .cgi extension.

Ruby does not work with .rb extension.

 

http://alexanderhawley.com/cgi-bin/testruby.cgi

#!/usr/bin/ruby
print "Content-type: text/html\n\n"
print "ruby"

 

http://alexanderhawley.com/cgi-bin/testruby.rb

#!/usr/bin/ruby
print "Content-type: text/html\n\n"
print "ruby"

 

 

Thoughts?

 

Thanks.

 

 

-AH

Link to comment
Share on other sites

Okay, so it looks like it should work without adding any handlers.

 

According to the HelioHost feature info.

 

http://heliohost.org/home/features-mainmen...enu/rubyonrails

Ruby scripts are easy to configure and run. Just create a file in your cgi-bin directory under public_html, and place the Ruby "shebang" line (#!/usr/bin/ruby) on the first line of the file. Below this line you may write Ruby code. Make sure you make this file's CHMOD permissions 755, and output a Content-type header before anything else.

However, "Just create a file" isn't accurate.

 

Perl is the only language that works with any file extension and no file extension.

 

Python works with .cgi and .py extensions and no extension.

 

Ruby works with .cgi extension and no extension.

 

Thoughts?

 

Thanks.

 

 

-AH

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...