在Godaddy Deluxe运行Ruby脚本

网上有很多文章介绍怎么在Godaddy的空间上跑Ruby on Rails,但是怎么单独运行Ruby脚本,却很少有提及。和Perl、php相比,Ruby更灵活,更省力。
我们看下面这个例子:

#!/usr/local/bin/ruby -w
# index.cgi
puts "Content-Type: text/html"
puts
puts "Hello World!"

把上面这段脚本上传到Godady的空间里,任意目录都可以。然后将这个文件的属性改为755(大部分FTP软件都能做到)。

这样你就可以看这个脚本运行了,比如:http://www.yoursite.com/main.cgi

注意,脚本的名字一定要以cgi作扩展名,而不是rb。

如果要用gems,可以这样

require "rubygems"
require "mysql"

2 thoughts on “在Godaddy Deluxe运行Ruby脚本

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>