Use Ruby Scripts2015/06/02 |
Configure httpd to use Ruby as CGI scripts.
|
|
[1] | Install Ruby. |
[root@www ~]# dnf -y install ruby
|
[2] | Configure httpd. |
[root@www ~]#
vi /etc/httpd/conf/httpd.conf # line 247: by default, it is allowed to use CGI scripts under the "/var/www/cgi-bin/". # but all files under it is looked as CGI by default. ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" # if you use CGI scripts under any directory and specify files for CGI, add settings like follows # line 144: change ( enable CGI, remove Indexes ) Options FollowSymLinks ExecCGI
# line 294: uncomment and add extentions for CGI AddHandler cgi-script .cgi .rb
systemctl restart httpd |
[3] | Create a Ruby test page and access to it from client PC with web browser. It's OK if following page is shown. |
[root@www ~]#
vi /var/www/html/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 Time.now.strftime('%Y/%m/%d') print "\n</div>\n" print "</body>\n</html>\n" chmod 705 /var/www/html/index.rb |
Sponsored Link |