From: "Bambang Purnomosidi D. P." Date: 2001-11-27T10:27:46+09:00 Subject: [ruby-talk:26584] Re: CGI Dear Clayton Wozney, This question is raised by someone in India (Suresh or something I forgot), I answered it but your answer is far more details, so, if you do not mind, I forward this to the mailing list so that hopefully this will help him. Thanks. -- bpdp On Tuesday 27 November 2001 3:44 am, Clayton Wozney wrote: > Hello, > > I just recently got this going and I am an ultra-newbie Ruby guy (as well > as knowing virtually nothing about Apache). Here is what I/you need to do: > > 1. I installed Apache on my machine (I have a Win2K box) > 2. As a default, I put my .rb files into /cgi-bin/ under Apache > 3. Here is the kicker... malke sure that you have a shebang line in your > .rb file telling Apache were to find the Ruby interpeter. This should be > the first line of the file. Here is what mine looks like for Win2k: > #!/ruby/bin/ruby > Notice the use of forward-slashes in the path. > For *nix, your shebang line should look something like: > #1/usr/local/bin/ruby (this is from page xxviii of the pick axe book) > 4. You may have to fiddle around with the Apache httpd.conf file to enable > the ScriptAlias directive. I think mine was set up with the correct path > but I think it was commented out. If you change anything in a .conf file > you will have to start and stop Apache for the change to take effect. > 5. To access this from a browser, enter http://localost/cgi-in/test.rb for > the URL where test.rb is replaced wth the actual name of your script file. > > This worked for me, but I would start with a simpler script because I found > it easy to make a typo and then the page won't load. Here is what I > started with and got to work: > > #!/ruby/bin/ruby > require "cgi" > cgi = CGI.new("html3") > cgi.out { > CGI.pretty ( > cgi.html { > cgi.head { cgi.title{"TITLE"} } + > cgi.body { > cgi.h1 { "This is big!" } > } > } > ) > } > > Note that CGI.pretty is a function call (hencer the () rather than {}). I > hope this helps. > > Clayton. > > P.S. I'm emailing you directly because I can't seem to reply post to the > newsgroup... hmmm.