在ubuntu下

进入 /usr/lib/cgi-bin目录 新建文件 ruby.cgi

内容如下

#!/usr/bin/ruby 
print "Content-type: text/html\r\n\r\n" 
print "<html><body>Hello World! It's #{Time.now}</body></html>\r\n" 

为文件加可执行权限 sudo chmod a+x ruby.cgi

重启apache2  sudo apache2 restart

打开火狐浏览器地址:localhost/cgi-bin/ruby.cgi

在windows下

只需更改ruby的安装路径,比如我的是C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe

#!C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe
print "Content-type: text/html\r\n\r\n" 
print "<html><body>Hello World! It's #{Time.now}</body></html>\r\n" 

参考:

Ruby CGI编程教程 http://www.yiibai.com/ruby/ruby_web_applications.html

http://www.cppblog.com/AutomateProgram/archive/2013/01/06/197009.html

相关文章:

  • 2021-08-06
  • 2021-06-14
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2021-05-08
  • 2021-05-20
  • 2021-12-20
猜你喜欢
  • 2021-11-29
  • 2022-12-23
  • 2021-12-03
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
相关资源
相似解决方案