[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Apache and Ruby

Phillip Neiswanger

12/6/2006 3:16:00 AM

Hi,

New to ruby and apache. Been trying to get a simple ruby script to run =
=

via apache. The script is as follows:

#!/usr/bin/env ruby
require "cgi"
cgi =3D CGI.new("html3")
cgi.out("text/plain"){
"Hello World"
}

I attempt to access it with my browser via an address like: =

http://127.0.0.1.... Apache is clearly not running ruby since I =
=

get the script back verbatim to the browser. Plain html, ie no ruby, is=
=

working. So far, in my search for an answer I haven't found anything to=
=

alleviate my problems. Interestingly, I have eRuby working, ie I can =

embed ruby code in my html, but not ruby. What special Apache incantati=
on =

do I need to get it working? I'm running Opera/FireFox, Apache 2.2.3 an=
d =

Ruby 1.8.5 on FreeBSD 6.1 system. I am not interested in getting rails =
=

working right now, just ruby.

Any help would be appreciated.
--
phil

7 Answers

Justin Collins

12/6/2006 6:44:00 AM

0

Phillip Neiswanger wrote:
> Hi,
>
> New to ruby and apache. Been trying to get a simple ruby script to
> run via apache. The script is as follows:
>
> #!/usr/bin/env ruby
> require "cgi"
> cgi = CGI.new("html3")
> cgi.out("text/plain"){
> "Hello World"
> }
>
> I attempt to access it with my browser via an address like:
> http://127.0.0.1.... Apache is clearly not running ruby since
> I get the script back verbatim to the browser. Plain html, ie no
> ruby, is working. So far, in my search for an answer I haven't found
> anything to alleviate my problems. Interestingly, I have eRuby
> working, ie I can embed ruby code in my html, but not ruby. What
> special Apache incantation do I need to get it working? I'm running
> Opera/FireFox, Apache 2.2.3 and Ruby 1.8.5 on FreeBSD 6.1 system. I
> am not interested in getting rails working right now, just ruby.
>
> Any help would be appreciated.
> --
> phil

Do you have mod_ruby installed?

-Justin

Phillip Neiswanger

12/6/2006 7:36:00 AM

0

On Tue, 05 Dec 2006 23:43:32 -0700, Justin Collins <collinsj@seattleu.ed=
u> =

wrote:

> Phillip Neiswanger wrote:
>> Hi,
>>
>> New to ruby and apache. Been trying to get a simple ruby script to r=
un =

>> via apache. The script is as follows:
>>
>> #!/usr/bin/env ruby
>> require "cgi"
>> cgi =3D CGI.new("html3")
>> cgi.out("text/plain"){
>> "Hello World"
>> }
>>
>> I attempt to access it with my browser via an address like: =

>> http://127.0.0.1.... Apache is clearly not running ruby since=
I =

>> get the script back verbatim to the browser. Plain html, ie no ruby,=
=

>> is working. So far, in my search for an answer I haven't found =

>> anything to alleviate my problems. Interestingly, I have eRuby =

>> working, ie I can embed ruby code in my html, but not ruby. What =

>> special Apache incantation do I need to get it working? I'm running =
=

>> Opera/FireFox, Apache 2.2.3 and Ruby 1.8.5 on FreeBSD 6.1 system. I =
am =

>> not interested in getting rails working right now, just ruby.
>>
>> Any help would be appreciated.
>> -- phil
>
> Do you have mod_ruby installed?
>
> -Justin

Thanks for the reply Justin. I fixed my problems with the following lin=
es =

in httpd.conf

Options ExecCGI
AddHandler cgi-script .rb

I also had to make sure the .rb files had the appropriate group ownershi=
p.
--
phil

pere.noel

12/6/2006 9:30:00 AM

0

Phillip Neiswanger <sigsegv@prodigy.net> wrote:

>
> Thanks for the reply Justin. I fixed my problems with the following lines
> in httpd.conf
>
> Options ExecCGI
> AddHandler cgi-script .rb
>
> I also had to make sure the .rb files had the appropriate group ownership.

And u don't need a special folder under your Apache/ROOT folder ?

--
Père Noël

Justin Collins

12/6/2006 9:51:00 AM

0

Père Noël wrote:
> Phillip Neiswanger <sigsegv@prodigy.net> wrote:
>
>
>> Thanks for the reply Justin. I fixed my problems with the following lines
>> in httpd.conf
>>
>> Options ExecCGI
>> AddHandler cgi-script .rb
>>
>> I also had to make sure the .rb files had the appropriate group ownership.
>>
>
> And u don't need a special folder under your Apache/ROOT folder ?

No, you don't have to set it up that way, although it's an option.

-Justin

pere.noel

12/6/2006 11:22:00 AM

0

Justin Collins <collinsj@seattleu.edu> wrote:

> > And u don't need a special folder under your Apache/ROOT folder ?
>
> No, you don't have to set it up that way, although it's an option.

in the mean time i've installed mod_ruby.

then i've tried that using an hello_world cgi this one :

<http://www.yvon-thoraval.com/ruby/hello...

works as expected

and that one :

<http://www.yvon-thoraval.com/httpd/hello_wor...

generates a 404 errror even if u've accessed to it by it's parent
folder...


the content of both is the same except i write a shebang for the latest
(rbx) :

#! /usr/bin/env ruby

cgi=CGI.new
print cgi.header("type" => "text/plain")
print "Hello World !"


u can see txt files at the same adresses extension added ".txt"

the added Apache directives are in the following file :

<http://www.yvon-thoraval.com/httpd/mod_ruby_http...

also both files are executables...


--
Père Noël

Justin Collins

12/6/2006 11:49:00 AM

0

Père Noël wrote:
> Justin Collins <collinsj@seattleu.edu> wrote:
>
>
>>> And u don't need a special folder under your Apache/ROOT folder ?
>>>
>> No, you don't have to set it up that way, although it's an option.
>>
>
> in the mean time i've installed mod_ruby.
>
> then i've tried that using an hello_world cgi this one :
>
> <http://www.yvon-thoraval.com/ruby/hello...
>
> works as expected
>
> and that one :
>
> <http://www.yvon-thoraval.com/httpd/hello_wor...
>
> generates a 404 errror even if u've accessed to it by it's parent
> folder...
>
>
> the content of both is the same except i write a shebang for the latest
> (rbx) :
>
> #! /usr/bin/env ruby
>
> cgi=CGI.new
> print cgi.header("type" => "text/plain")
> print "Hello World !"
>
>
> u can see txt files at the same adresses extension added ".txt"
>
> the added Apache directives are in the following file :
>
> <http://www.yvon-thoraval.com/httpd/mod_ruby_http...
>
> also both files are executables...
>

My mistake...I'm not much of an expert on this. You will need to add a
directory directive like:

<Directory /var/www/html/somedir/*>
Options +ExecCGI
</Directory>

in the config file to have it work right. Sorry about that.

-Justin

pere.noel

12/6/2006 7:08:00 PM

0

Justin Collins <collinsj@seattleu.edu> wrote:

> My mistake...I'm not much of an expert on this. You will need to add a
> directory directive like:
>
> <Directory /var/www/html/somedir/*>
> Options +ExecCGI
> </Directory>
>
> in the config file to have it work right. Sorry about that.

why did u say it's your mistake ?
because i've found these directives from mod_ruby archive ;-)

anyway that cures the prob, thanks a lot !
--
Père Noël