Creating a ruby "CGI" script

B

barjunk

I have been working with one of the Mentors from
rubymentor.rubyforge.org. Through our e-mail conversation and some
experimenting, I learned several things. I am posting them here
because I think it is helpful to all who might come after me and to
show my appreciation for the help that has been given.

There were several parts to making a 'CGI' script using ruby:

- Configuring the apache server(that's what I was using): Some
important points are to have the Options +ExecCGI options for your
particular site and for ScriptAlias to be pointing at the directory
that contains the intended ruby script. Looking at the apache log
files started me in the right direction for these things.

- Writing the script: There is a reasonable example in the online
book ( http://www.ruby-doc.org/docs/ProgrammingRuby/html/web.html ).
However, what it didn't mention is that you can test things by
executing the program on the command line and providing your
environment variables to the script followed by a control-D. I found
this after googling a little.

- Setting permissions: This is obvious for most people...but it
should be mentioned. The permissions on your script need to be set so
that your webserver will be able to read and execute them ( anyone
want to share best practices here?)

It would be great if others with way more experience could clear up
any mistatements I might have made because of my lack of experience.
Best practices examples are most welcome.

Thanks.

Mike B.
 
S

SonOfLilit

I have been working with one of the Mentors from
rubymentor.rubyforge.org. Through our e-mail conversation and some
experimenting, I learned several things. I am posting them here
because I think it is helpful to all who might come after me and to
show my appreciation for the help that has been given.

There were several parts to making a 'CGI' script using ruby:

- Configuring the apache server(that's what I was using): Some
important points are to have the Options +ExecCGI options for your
particular site and for ScriptAlias to be pointing at the directory
that contains the intended ruby script. Looking at the apache log
files started me in the right direction for these things.

- Writing the script: There is a reasonable example in the online
book ( http://www.ruby-doc.org/docs/ProgrammingRuby/html/web.html ).
However, what it didn't mention is that you can test things by
executing the program on the command line and providing your
environment variables to the script followed by a control-D. I found
this after googling a little.

- Setting permissions: This is obvious for most people...but it
should be mentioned. The permissions on your script need to be set so
that your webserver will be able to read and execute them ( anyone
want to share best practices here?)

It would be great if others with way more experience could clear up
any mistatements I might have made because of my lack of experience.
Best practices examples are most welcome.

Thanks.

Mike B.

Hello Mike,

glad you benefited from RubyMentor.

Would you two agree to post your conversation logs to the wiki?
Currently there's only mine and Samantha's, and I'd like there to be
more examples.

That and it being a great resource, too.


Aur
 

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

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top