# Lighttpd / WEBrick forum?

**URL:** <https://www.ruby-forum.com/t/lighttpd-webrick-forum/76963>\
**Category:** Rails\
**Created:** [March 5, 2006, 6:49pm UTC](https://www.ruby-forum.com/t/lighttpd-webrick-forum/76963 "2006-03-05T18:49:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [March 5, 2006, 6:49pm UTC](https://www.ruby-forum.com/t/lighttpd-webrick-forum/76963/1 "2006-03-05T18:49:33Z")

</div>

Is there a mail list or USENET group for lighttpd WEBrick questions.

I posted a simple CGI question to this list last week and got one  
responce and that responce told me I was on the wrong list with Ruby  
based from / CGI questions.

The code I posted looks correct but does not work giving a Routing  
Error. This makes me think something is wrong with the set up of  
WEBrick. I am only doing the default “rails someapp” and running  
WEBrick with script/server -p3020. The CGI does not work (original  
post below). This makes me think I need to go to some WEBrick  
knowledge. Where can I find it?

john

####################################################  
Original post:  
####################################################  
Ok … if you are sensitive … stop reading.

I am totally new to setting up CGI. I am getting a routing error.  
Would someone be kind enough to help me? Please?

Here is my form …

 Form | Contact A #I have tried text/plain

I put this in the public folder of a rails WEBrick app.

Here is my Ruby CGI …

###################################################  
#!/opt/local/bin/ruby -w

text = “dog”  
print “Content-type: text/html\r\n\r\n”  
print “”  
print “ **_Hello_, #{ text} !** ”  
print “”  
##################################################  
I put this in cgi-bin directory in the same dir as the forms.html  
file. Permissions on the Ruby script where set to 775. My intention  
is not to handle any input from the forms.html file but just to get  
back a simple "“Hello dog” after the submit.

here is what i get when i run WEBrick and hit the Submit button …

Routing Error

Recognition failed for “cgi-bin/parse.rb”

Can anyone help me. I am not sure if this is a problem with my code,  
WEBrick of the form.

Thanks and don’t be shy … i have a thick skin.

john

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [March 6, 2006, 9:33am UTC](https://www.ruby-forum.com/t/lighttpd-webrick-forum/76963/2 "2006-03-06T09:33:23Z")

</div>

There are some general Ruby lists here:

[http://www.ruby-lang.org/en/20020104.html](http://www.ruby-lang.org/en/20020104.html)

And I’m still confused as to what you are trying to do. Ruby on Rails is  
not just a simple  
CGI tool.

You say that you’re using a rails app, but then you are just trying to  
get a CGI script to  
fire. That’s not how rails works… it expects a specific directory  
structure of ruby  
files and uses those to process a given request URL. Simply doing  
[myhost.com/cgi-bin/myrubyfile.rb](http://myhost.com/cgi-bin/myrubyfile.rb) is not going to work… even remotely.

If you are interested in using rails to serve dynamic content, you  
should read through  
some of the docs at [rubyonrails.com](http://rubyonrails.com). If you just want to get a CGI  
script to run, don’t  
bother with rails; look at the docs for you webserver on how to set up  
CGI scripts. As  
long as you have ruby installed and your shebang line is correct, the  
script should get run.

Good luck.

b

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [March 6, 2006, 2:57pm UTC](https://www.ruby-forum.com/t/lighttpd-webrick-forum/76963/3 "2006-03-06T14:57:44Z")

</div>

Thank you this is why I am asking for a lighttpd / WEBrick forum.

I am using the Rails structure only to “create” an environment to run  
WEBrick from. I am then using WEBrick to try to do simple Ruby CGI.  
The script I posted in my original query does work in a simulated  
server environment (Komodo). I now just want to move this to a real  
server environment. I created a Rails directory and then im using  
WEBrick out of it just … creating a directory, … putting the CGI  
script in that dir, … setting permissions to 775 and seeing if it  
works. It don’t. So I am now assuming there is a problem with my  
assumption that I can have a working web server out of a Rails set up  
that will do simple CGI.

Peace  
john

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [March 6, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/lighttpd-webrick-forum/76963/4 "2006-03-06T17:57:37Z")

</div>

Yeah, I don’t know anything about using WEBrick freestanding other than  
it should be  
possible (WEBrick pre-dates rails). And I think that any HTTP server  
should be able to do  
CGI since it’s just “run this and dump it’s output into the response  
stream”… more or less.

Well, you should probably look through the docs:

[http://www.webrick.org/](http://www.webrick.org/)  
[http://www.lighttpd.net/](http://www.lighttpd.net/)  
or for that matter…  
[http://httpd.apache.org/](http://httpd.apache.org/)

There should be something about running CGIs in there somewhere. I’d bag  
the whole idea of  
using a rails app though. All you really need is a cgi-bin directory and  
a public  
directory and the proper config in whatever server you are using.

b

PS: and I have no idea why I’m the only person answering you… ☹

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [March 6, 2006, 6:43pm UTC](https://www.ruby-forum.com/t/lighttpd-webrick-forum/76963/5 "2006-03-06T18:43:18Z")

</div>

I’m not sure why you’d want to do that. If all you want is WEBrick,  
just require/include it in your ruby code and go from there. Have a  
look at the WEBrick docs (it’s a part of the Ruby distro–Rails not  
needed)

Jamie

---

<div class="post-metadata">

**Author:** ![John\_NSAlegre](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@John\_NSAlegre](https://www.ruby-forum.com/u/John_NSAlegre)\
**Post date:** [March 6, 2006, 9:39pm UTC](https://www.ruby-forum.com/t/lighttpd-webrick-forum/76963/6 "2006-03-06T21:39:56Z")

</div>

John-

```
Hopefully this info should get you going with your cgi servlet. The

```

following is a custom webrick servlet that will serve html or cgi  
scripts right out of the doc root that you specify:

#!/usr/local/bin/ruby  
require ‘webrick’  
require ‘webrick/cgi’  
include WEBrick

server = WEBrick::HTTPServer.new

def start\_webrick(config = {})  
config.update(:Port =\> 8000)  
server = HTTPServer.new(config)  
yield server if block\_given?  
[‘INT’, ‘TERM’].each {|signal|  
trap(signal) {server.shutdown}  
}  
server.start  
end

start\_webrick {|server|

# replace the next line with your doc root that you want to use.

doc\_root = ‘/Volumes/Users/ez/webrick’  
server.mount(“/”, HTTPServlet::FileHandler, doc\_root,  
{:FancyIndexing=\>true})  
}

Save that code into a file and run it from the command line. You can  
change the port number that it uses in the start\_webrick method. then  
just put your html and cgi scripts in the doc root and go to town.  
Your cgi scripts will need to have .cgi as the extension in order to  
work correctly. Here is a simple cgi script that you can test to see  
if things are working for you:

#!/usr/bin/env ruby  
print “Content-type: text/plain\r\n\r\n”  
ENV.keys.sort.each{|k| puts “#{k} ==\> #{ENV[k]}”}

Cheers-

-Ezra Z.  
Yakima Herald-Republic  
WebMaster

> **[yakimaherald.com | Yakima, Washington - We Tell Your Stories](https://www.yakimaherald.com/)**

509-577-7732  
removed\_email\_address@domain.invalid
