Fedora 16
Sponsored Link

Ruby インストール2011/11/12

 
Rubyをインストールして CGI として使えるようにします。
[1] Ruby インストール
[root@www ~]#
yum -y install ruby
[root@www ~]#
vi /etc/httpd/conf/httpd.conf
# 795行目:Rubyスクリプトとして扱う拡張子を追記

# Rubyスクリプトも拡張子「.cgi」とするなら追記の必要なし

AddHandler cgi-script .cgi .pl
.rb
[root@www ~]#
systemctl restart httpd.service

[2] Rubyテストページを作成して動作確認をします。作成したテストページにWebブラウザでアクセスして、以下のようなページが表示されればOKです。
[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" 

[root@www ~]#
chmod 705 /var/www/html/index.rb

関連コンテンツ