티스토리 뷰

OpenSUSE 11 Apache2 Use Ruby Scripts


Use Ruby Scripts

 

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>


www:~ # /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" 


www:~ # chmod 705 /srv/www/htdocs/cgi-enabled/index.rb 



5. Access to 'http://(your server's name or IP address)/cgi-enabled/index.rb 



저작자 표시 비영리 변경 금지
신고
댓글