让Apache支持ruby写的cgi程序

1,按说明安装ruby的apache mod
2,配置文件如下:

1 #########################################################
2 # ruby cgi 配置
3 #########################################################
4 LoadModule ruby_module /usr/lib/httpd/modules/mod_ruby.so
5
6 <IfModule mod_ruby.c>
7 RubyRequire apache/ruby-run
8 <Files *.rbx><!--不要误以为源文件以.rbx结尾,还是.rb(在windows下要用.rb)-->
9 SetHandler ruby-object
10 RubyHandler Apache::RubyRun.instance
11 </Files>
12 RubyRequire apache/eruby-run
13 <Files *.rhtml>
14 SetHandler ruby-object
15 RubyHandler Apache::ERubyRun.instance
16 </Files>
17 #for debug
18 RubyRequire auto-reload
19 </IfModule>

windows:说明
先装:RubyForApache-1.3.1.exe
后装:eruby-1.0.5-i386-mswin32-1.8.zip

另外如果要让IIS支持Ruby写的CGI,只需

在CGI-Bin目录下单击右键,在“虚拟目录”的配置按钮中加入.rb的映射,可执行文件选择E:\ruby\bin\ruby.exe "%s" %s,在“目录安全性”标签页中,设置“身份验证和访问控制“为匿名访问(此处为测试用,真正的CGI系统中应加入此项,以加强安全性).

至此可在浏览器中开始用CGI了-:)

原文地址:https://www.cnblogs.com/djcsch2001/p/2035822.html