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/script.rb. 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
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/script.rb\. 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 lines in httpd.conf
Options ExecCGI
AddHandler cgi-script .rb
I also had to make sure the .rb files had the appropriate group ownership.
···
On Tue, 05 Dec 2006 23:43:32 -0700, Justin Collins <collinsj@seattleu.edu> wrote:
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/script.rb\. 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
--
phil
And u don't need a special folder under your Apache/ROOT folder ?
···
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.
--
Père Noël
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_world>
works as expected
and that one :
<http://www.yvon-thoraval.com/httpd/hello_world.rbx>
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_httpd.conf>
also both files are executables...
···
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.
--
Père Noël
Père Noël 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_world>
works as expected
and that one :
<http://www.yvon-thoraval.com/httpd/hello_world.rbx>
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_httpd.conf>
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
···
Justin Collins <collinsj@seattleu.edu> wrote:
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 !
···
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.
--
Père Noël
Justin Collins wrote:
Père Noël 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.
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
A point to note that was lost, it doesn't have to be a special folder,
and it's a bad idea to do so. Same for using the extension-based handler.
Cf. Hypertext Style: Cool URIs don't change., section on "What to leave out"
(Of course, you can safely ignore those guidelines when playing around,
just keep them in mind for "real" projects. On a related note, I also
find the slashified (in buzzwordspeak: RESTful) URLs sexy-looking as far
as URLs go ;P)
David Vallner
···
Justin Collins <collinsj@seattleu.edu> wrote:
A point to note that was lost, it doesn't have to be a special folder,
and it's a bad idea to do so. Same for using the extension-based handler.
Cf. Hypertext Style: Cool URIs don't change., section on "What to leave out"
content negociation is doable with Apache 1.3 (default installed version
within MacOS X latest) ?
(Of course, you can safely ignore those guidelines when playing around,
just keep them in mind for "real" projects. On a related note, I also
find the slashified (in buzzwordspeak: RESTful) URLs sexy-looking as far
as URLs go ;P)
do you have an example, a link about that "slashified" URLs ?
···
David Vallner <david@vallner.net> wrote:
--
Père Noël
Père Noël wrote:
A point to note that was lost, it doesn't have to be a special folder,
and it's a bad idea to do so. Same for using the extension-based handler.
Cf. Hypertext Style: Cool URIs don't change., section on "What to leave out"
content negociation is doable with Apache 1.3 (default installed version
within MacOS X latest) ?
There's a mod_negotiation section in the manual for that version, so it
seems so. I'm hazy about the details since I rarely use CGI.
(Of course, you can safely ignore those guidelines when playing around,
just keep them in mind for "real" projects. On a related note, I also
find the slashified (in buzzwordspeak: RESTful) URLs sexy-looking as far
as URLs go ;P)
do you have an example, a link about that "slashified" URLs ?
For a mailing list (more or less) relevant one,
http://manuals.rubyonrails.com/read/chapter/65 describes a Rails feature
that lets you have those.
David Vallner
···
David Vallner <david@vallner.net> wrote:
There's a mod_negotiation section in the manual for that version, so it
seems so. I'm hazy about the details since I rarely use CGI.
ok fine, i've verified in the mean time, content negociation does exist
with Apache 1.3
>> (Of course, you can safely ignore those guidelines when playing around,
>> just keep them in mind for "real" projects. On a related note, I also
>> find the slashified (in buzzwordspeak: RESTful) URLs sexy-looking as far
>> as URLs go ;P)
>
> do you have an example, a link about that "slashified" URLs ?
For a mailing list (more or less) relevant one,
http://manuals.rubyonrails.com/read/chapter/65 describes a Rails feature
that lets you have those.
ok fine,thanks !
···
David Vallner <david@vallner.net> wrote:
--
Père Noël