# My "Hello World" script is not displaying properly

**URL:** <https://www.ruby-forum.com/t/my-hello-world-script-is-not-displaying-properly/84141>\
**Category:** Ruby\
**Created:** [February 1, 2007, 8:50pm UTC](https://www.ruby-forum.com/t/my-hello-world-script-is-not-displaying-properly/84141 "2007-02-01T20:50:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 1, 2007, 8:50pm UTC](https://www.ruby-forum.com/t/my-hello-world-script-is-not-displaying-properly/84141/1 "2007-02-01T20:50:56Z")

</div>

Hi,

I just installed mod\_ruby1.2.5 with Apache 2.2.3 on Fedora Core 5  
Linux. Triumphant, I downloaded this test script to my web root  
(public\_html/test.rbx)

#!/usr/local/bin/ruby  
print “HTTP/1.0 200 OK\r\n”  
print “Content-type: text/html\r\n\r\n”  
print “Hello World!\r\n”

I restarted my web server but when I load the page in IE, I get

HTTP/1.0 200 OK Content-type: text/html Hello World!

and on Firefox …

HTTP/1.0 200 OK  
Content-type: text/html

Hello World!

What is wrong? Below is what I added to my httpd.conf file …

LoadModule ruby\_module /usr/local/apache2/modules/mod\_ruby.so

## On Linux (FC3) this becomes

# LoadModule ruby\_module /usr/lib/httpd/modules/mod\_ruby.so

# ClearModuleList

# AddModule mod\_ruby.c
 RubyRequire apache/ruby-run
# Execute files under /ruby as Ruby scripts

\<Location /ruby\>  
SetHandler ruby-object  
RubyHandler Apache::RubyRun.instance

# Execute \*.rbx files as Ruby scripts

\<Files \*.rbx\>  
SetHandler ruby-object  
RubyHandler Apache::RubyRun.instance

Thanks, - Dave

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [February 1, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/my-hello-world-script-is-not-displaying-properly/84141/2 "2007-02-01T21:32:04Z")

</div>

On Fri, Feb 02, 2007 at 04:50:10AM +0900, removed\_email\_address@domain.invalid  
wrote:

> What is wrong?

It did what you told it to 🙂 If you do the following, you should see  
why:

telnet 127.0.0.1 80  
GET /test.rbx HTTP/1.0  
Host: localhost

If I’m right, the web server has already output a HTTP/1.0 response, so  
your  
script is outputting a second one, which the client sees is not a valid  
header, so treats it as the response body.

If you really want your Ruby program to generate the HTTP response,  
you’ll  
need to configure your webserver to run it as an nph script. Maybe  
renaming  
it to nph-test.rbx will be sufficient. Otherwise just remove the first  
print  
line from your script.

Regards,

Brian.
