I wish to use Ruby in Apache through CGI. I've the next during my configuration file:
DocumentRoot /home/ceriak/ruby <Directory /home/ceriak/ruby> Options +ExecCGI AddHandler cgi-script .rb </Directory>
test.rb is really a testfile placed directly under
#!/usr/bin/ruby incorporated around the first line and given executable permissions. Still, after i visit
localhost/test.rb I recieve a download window and may have the source code.
Oddly enough, after i put the same script under
/usr/lib/cgi-bin/ and call
localhost/cgi-bin/test.rb it really works as supposed.
(Apache2 on Ubuntu 9.10.)
Couple of items to check:
- is the file executable?
- have you output the right Content-type?
- it is possible to blank newline involving the headers as well as your output?
- have you restart Apache after setting the configuration?
Should you did everything, it will work fine. I've this as my test.rb file:
#!/usr/bin/env ruby puts <<EOS Content-type: text/html <html><body>hi</body></html> EOS