Ruby and Lighttpd/FastCGI

  • Thread starter Rüdiger Sonderfeld
  • Start date
R

Rüdiger Sonderfeld

hi,
I'm trying to write a FastCGI script with Ruby and Lighttpd.

I'm using ruby-fcgi 0.8.6, ruby 1.8.2 and lighttpd 1.3.11 (Ubuntu-Linux).

I have setup lighttpd with the following parameters
fastcgi.server = (".rb" =>
( "localhost" =>
( "socket" => "/tmp/rb-fastcgi.socket" )
)
)

I wrote a ruby script similar to
http://www.rubygarden.org/ruby?FCGIExternalServer

#!/usr/bin/ruby
FCGI_PURE_RUBY=true
require 'socket'
require 'cgi'
require 'fcgi'

socket = UNIXServer.new('/tmp/rb-fastcgi.socket')
class << socket
alias :eek:ldaccept :accept
def accept
[oldaccept, nil]
end
end

FCGI::Server.new(socket).each_request do |request|
Thread.start {
request.out.print "Content-type: text/html\r\n"
request.out.puts "<html><head><title>Foo</title></head><body><b>Yeah</b></body></html>"
request.finish
}
end

I start the script (as user www-data) and restart lighttpd.
But trying to access the script from a browser does not return any results.

lighttpd's errorlog is empty and the http connection is normal.

Any ideas?

Regards,
Rüdiger Sonderfeld <[email protected]>
 
A

Aredridel

hi,
I'm trying to write a FastCGI script with Ruby and Lighttpd.
=20
I'm using ruby-fcgi 0.8.6, ruby 1.8.2 and lighttpd 1.3.11 (Ubuntu-Linux).
=20
I have setup lighttpd with the following parameters
fastcgi.server =3D (".rb" =3D>
( "localhost" =3D>
( "socket" =3D> "/tmp/rb-fastcgi.socket= " )
)
)

I always use lighttpd's spawn-fcgi tool for this -- skip the UnixServer
bit in your ruby code, and just do the FCGI.each loop.

Ari
 
R

Rüdiger Sonderfeld

Aredridel said:
I always use lighttpd's spawn-fcgi tool for this -- skip the UnixServer
bit in your ruby code, and just do the FCGI.each loop.

It seems to be a problem within the request code. Even with spawn-fcgi it did
not work until I used the CGI Interface

#!/usr/bin/ruby
require 'cgi'
require 'fcgi'

FCGI.each_cgi do |cgi|
cgi.out("text/html") { "<b>Ruby FCGI</b>" }
end

Thanks a lot.

Regards,
Rüdiger Sonderfeld <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top