# Apache2.2 and ruby script

**URL:** <https://rubytalk.org/t/apache2-2-and-ruby-script/32453>\
**Category:** ruby-talk\
**Created:** [28 October 2006 20:04 UTC](https://rubytalk.org/t/apache2-2-and-ruby-script/32453 "2006-10-28T20:04:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guest2](https://avatars.discourse-cdn.com/v4/letter/g/439d5e/32.png) [@Guest2](https://rubytalk.org/u/Guest2)\
**Post date:** [28 October 2006 20:04 UTC](https://rubytalk.org/t/apache2-2-and-ruby-script/32453/1 "2006-10-28T20:04:04Z")

</div>

Hi guys,

Before I post the question I already search the forum about how to  
configure apache 2.2( under xp) to run Ruby script. I find one previous  
post and follow it: 1) add line #!c:/Ruby/bin/ruby.exe -w at the start  
of the script 2) change the file extension as .cgi 3) add a line  
AddHandler cgi-script .cgi .pl in httpd.conf file. (No problem to run  
the perl script)

####cgi1.cgi

#!c:/Ruby/bin/ruby.exe -w  
&nbsp;&nbsp;print "HTTP/1.0 200 OK\r\n"  
&nbsp;&nbsp;print "Content-type: text/html\r\n\r\n"  
&nbsp;&nbsp;print "\<html\>\<body\>Hello World!\</body\>\</html\>\r\n"

> **···**
>
> ####  
> I can run the script from prompt window and get the following output
> 
> C:\Program Files\Apache Software Foundation\Apache2.2\cgi-bin\>ruby  
> cgi1.cgi  
> HTTP/1.0 200 OK  
> Content-type: text/html
> 
> \<html\>\<body\>Hello World!\</body\>\</html\>
> 
> But I can't run it from the IE browser. How can I fix it?
> 
> Thanks,
> 
> Li
> 
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Paul\_Lutus](https://avatars.discourse-cdn.com/v4/letter/p/2bfe46/32.png) [@Paul\_Lutus](https://rubytalk.org/u/Paul_Lutus)\
**Post date:** [28 October 2006 20:50 UTC](https://rubytalk.org/t/apache2-2-and-ruby-script/32453/2 "2006-10-28T20:50:14Z")

</div>

Li Chen wrote:

/ ...

> But I can't run it from the IE browser. How can I fix it?

Try this as a first line:

#!C:\Ruby\bin\ruby.exe -w

Remove this line (Apache provides it):

print "HTTP/1.0 200 OK\r\n"

See if that works.

> **···**
>
> --  
> Paul Lutus  
> [http://www.arachnoid.com](http://www.arachnoid.com)

---

<div class="post-metadata">

**Author:** ![Guest2](https://avatars.discourse-cdn.com/v4/letter/g/439d5e/32.png) [@Guest2](https://rubytalk.org/u/Guest2)\
**Post date:** [28 October 2006 22:13 UTC](https://rubytalk.org/t/apache2-2-and-ruby-script/32453/3 "2006-10-28T22:13:39Z")

</div>

Paul Lutus wrote:

> Try this as a first line:
> 
> #!C:\Ruby\bin\ruby.exe -w
> 
> Remove this line (Apache provides it):
> 
> print "HTTP/1.0 200 OK\r\n"
> 
> See if that works.

Hi Paul,

After I remove this line

print "HTTP/1.0 200 OK\r\n"

Thanks,

Li

> **···**
>
> from my script I can run the script from browser.
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
