在Apache中设置红宝石CGI

编程入门 行业动态 更新时间:2024-10-27 13:26:15
本文介绍了在Apache中设置红宝石CGI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想通过CGI使用Ruby在Apache中。我在我的配置文件中的以下内容:

I want to use Ruby in Apache through CGI. I have the following in my configuration file:

DocumentRoot /home/ceriak/ruby <Directory /home/ceriak/ruby> Options +ExecCGI AddHandler cgi-script .rb </Directory>

test.rb 正在放在testfile的的/ home / ceriak /红宝石/ ,#!的/ usr / bin中/红宝石包含在第一行,并给予可执行权限。不过,当我访问本地主机/ test.rb 我得到一个下载窗口,可以获取源$ C ​​$ C。

test.rb is a testfile placed under /home/ceriak/ruby/, #!/usr/bin/ruby included on the first line and given executable permissions. Still, when I visit localhost/test.rb I get a download window and can obtain the source code.

有趣的是,当我把在 / usr / lib目录/ cgi-bin目录/ 并调用本地主机/ cgi-bin目录/测试相同的脚本。 RB 它的工作原理像预想的那样。

Interestingly, when I place the same script under /usr/lib/cgi-bin/ and call localhost/cgi-bin/test.rb it works as supposed.

(Apache2的在Ubuntu 9.10)。

(Apache2 on Ubuntu 9.10.)

任何想法?

推荐答案

几件事情要检查:

  • 是您​​的文件的可执行文件?你可以把它可执行转到使用chmod + X /路径/要/文​​件
  • 你输出正确的内容类型?
  • 有你的头,你的输出之间的空白换行符?
  • 你将配置后,重新启动Apache?

如果你做了这一切,它应该工作的罚款。我有这个作为我test.rb文件:

If you did all that, it should work fine. I have this as my test.rb file:

#!/usr/bin/env ruby puts <<EOS Content-type: text/html <html><body>hi</body></html> EOS

更多推荐

在Apache中设置红宝石CGI

本文发布于:2023-10-26 20:38:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531282.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:红宝石   Apache   CGI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!