From: John Feezell Date: 2002-12-09T12:04:15+09:00 Subject: Re: eRuby (making it work -- file extensions) The following site gives information on the .htaccess file. It is used with the Apache web server. http://apache-server.com/tutorials/ATusing-htaccess.html Your file name is given as "first_steps.html" but for eRuby it should be rhtml, i.e., "first_steps.rhtml" and for Ruby the file extension should be either .rb or .rbx with .rbx being the "preferred" one, I believe. Also be sure for any Ruby files (.rbx) that the permissions are set to 755. On the eRuby files (.rhtml) should be set so that the owner can rw., the group can r.., and other can r.. that is mod 644. To verify that you can access the site via the browser, create the following file and place it in the directory. Then in the browser enter the URL: http://your.host.com/~dcarrera/ruby/0.2/index.html Create index.html using the following: Test Access Testing access via the browser. +++++++++++++ 12/8/2002 3:18:50 PM, Daniel Carrera wrote: >Thanks. But what is a '.htaccess' file? > >After I created it I couldn't view any of my webpages online. >The browser said: > >Forbidden >You don't have permission to access /~dcarrera/ruby/0.2/first_steps.html >on this server. > >Perhaps I have to add something to the .htaccess file to make the files >world readable? > >Daniel Carrera >Graduate Teaching Assisant. Math Dept. >University of Maryland. (301) 405-5137 > >On Sun, 8 Dec 2002, John Feezell wrote: > >> After much time and numereous attempts, I did the following to get both >> Ruby and eRuby working for me. >> >> What follows assumes telnet access and a directory (cgi-bin for me) that >> is recognized by the system as an active cgi script directory. >> >> Start description ============================== >> 1. installed Ruby using the -prefix=/my/path/to/ruby directory option >> If you need to, use ./configure --help to review options. >> >> 2. installed eRuby >> If necessary, change the shebang #! line in configure.rb >> to point to the location of ruby, i.e., >> #!/my/path/to/ruby >> >> 3. created a .htaccess file in my "webdocuments" directory that contained >> >> AddHandler cgi-script rb rbx >> >> AddHandler application/x-httpd-eruby .rhtml >> Action application/x-httpd-eruby /cgi-bin/eruby >> >> 4. moved eRuby to my cgi-bin directory >> >> 5. created GetEnv.rhtml containing: >> >> >> >> eruby example >> >> >>

Enumeration

>> >>

Environment variables

>> >> <%ENV.keys.sort.each do |key|%> >> >> >> >> <%end%> >>
<%=key%><%=ENV[key]%>
>> >> >> >> 6. created testRuby.rbx containing: >> #!/my/path/to/ruby >> # This is a working ruby script running ruby script with >> # extension .rb or .rbx >> # If the key for ENV does not exist, then ruby returns nil. >> # It requires the following modification to .htaccess in www >> # AddHandler cgi-script rb rbx >> # >> >> require 'date' >> print "Content-type: text/html\n\n" >> d = Date.new(2000, 3, 31) >> print $:,'

' >> print ENV['RUBYPATH'],'
' >> print [d.year, d.yday, d.wday] >> print "this is a test.", ENV['PATH'], "prefix= ",ENV['prefix'],"
" >> names = ["john", "mary", "", 4] >> data = [1, 2, 3, 4] >> data.each do |i | >> print i, " ", names[i-1],"
" >> end >> print "

Environment variables

" >> ENV.keys.sort.each do |key| >> print "" >> print "" >> end >> print "
",key,"", ENV[key], "
" >> >> 7. Ran GetEnv.rhtml and testRuby.rbx >> >> 8. They worked. >> WOW! EXCITEMENT! >> PHYSICAL EXPRESSIONS OF JOY! >> GREAT SENSE OF SATISFACTION! YES! WELL DONE! >> >> 9. Hope you have the same result -- a sense of accomplishment >> and the joy of working with Ruby and eRuby. >> End description ============================= >> >> >> 12/7/2002 8:14:51 PM, Daniel Carrera wrote: >> >> >Hello, >> > >> >I want to try out eRuby. I am only a regular user, so I can't install >> >mod_ruby and I can't mess with Apache. >> > >> >However, I have enough space in my home directory to install eRuby. >> > >> >Can anyone tell me how I can use eRuby with what I have? >> > >> >One thought is to make a cgi program which simply calls eRuby and then >> >outputs what ever eRuby returns. This solution is a bit ugly though. >> >Plus, I'd have trouble if I ever want the eRuby program to receive CGI >> >parameters. >> > >> >Thanks for the help. >> > >> >Daniel Carrera >> >Graduate Teaching Assisant. Math Dept. >> >University of Maryland. (301) 405-5137 >> > >> > >> > >> > >> > >> >> >> >> >> > > > >