Use Ruby Scripts2015/12/03 |
Configure Apache2 to use Ruby as CGI scripts.
|
|
[1] | Install Ruby. |
www:~ # zypper -n install ruby
|
[2] | By default, CGI is allowed under the "/srv/www/cgi-bin" directory. It's possible to use Ruby Scripts to put under the directory. All files under it are processed as CGI, though. |
# the settings below is the one for CGI www:~ # grep -n "^ *ScriptAlias" /etc/apache2/default-server.conf 60:ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/" |
[3] | If you'd like to allow CGI in other directories, configure like follows. For example, allow in "/srv/www/htdocs/cgi-enabled". |
www:~ #
vi /etc/apache2/conf.d/cgi-enabled.conf # create new # processes .rb as CGI scripts <Directory "/srv/www/htdocs/cgi-enabled"> Options +ExecCGI AddHandler cgi-script .rb </Directory> /etc/init.d/apache2 restart |
[4] | Create a CGI test page and access to it from client PC with web browser. It's OK if following page is shown. |
www:~ #
vi /srv/www/htdocs/cgi-enabled/index.rb #!/usr/bin/ruby print "Content-type: text/html\n\n" print "<html>\n<body>\n" print "<div style=\"width: 100%; font-size: 40px; font-weight: bold; text-align: center;\">\n" print "Ruby Script Test Page" print "\n</div>\n" print "</body>\n</html>\n" chmod 705 /srv/www/htdocs/cgi-enabled/index.rb |
Sponsored Link |