From: Ernest Ellingson Date: 2005-10-28T08:57:04+09:00 Subject: Re: help with fastcgi Ernest Ellingson wrote: > I'm really frustrated. > Is there a site where an example for httpd.conf using ruby fastcgi? > > I've looked through all of the threads on fastcgi at ruby-talk. Only > found one example for using fastcgi. > > I'm using Apache 2.x > > Here is my current httpd.conf relating to fastcgi > > LoadModule fastcgi_module modules/mod_fastcgi.so > > FastCgiIpcDir logs/fastcgi > ScriptAlias /fcgi-bin/ "/var/www/fcgi/ebw/" > > > AllowOverride All > Options None > Order allow,deny > Allow from all > SetHandler fastcgi-script > > > AddHandler fastcgi-script .fcgi I figured this out after some serious head scratching. Here is a short description of getting ruby_fcgi and mod_fastcgi for Apache to work. In httpd.conf you must have something like this # URIs that begin with /fcgi-bin/, are found in /var/www/fcgi-bin/ Alias /fcgi-bin/ /var/www/fcgi-bin/ FastCgiIpcDir /var/fcgi/ #FastCgiConfig -autoUpdate # Anything in here is handled as a "dynamic" server if not defined as"static" or "external" Order allow,deny Allow from all SetHandler fastcgi-script Options +ExecCGI AddHandler fastcgi-script .fcgi .fpl #------------------------------------------------------------------------- # Start a "static" server at httpd initialization FastCgiServer /var/www/ebw/echo Alias /ebw/ /var/www/ebw/ ------------End of httpd.conf-------------------------------- ----------sample scripts--------------------- A Dynamic fcgi script It starts and continues to run when browser points to http://somedomain/fci-bin/ebw/echo.fcgi cat /var/www/fcgi-bin/ebw/echo.fcgi #!/usr/local/bin/ruby require 'rubygems' require 'fcgi' require 'cgi' FCGI.each_cgi {|cgi| puts cgi.header puts "Connecting from #{cgi.remote_addr}
" puts "Time is now #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}" } A Static fcgi script It starts when the apache webserver starts It continues to run browser points to http://somedomain/ebw/echo #look at Alias in httpd.conf above. cat /var/www/ebw/echo #!/usr/local/bin/ruby require 'rubygems' require 'fcgi' require 'cgi' FCGI.each_cgi {|cgi| puts cgi.header puts "Connecting from #{cgi.remote_addr}
" puts "Time is now #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}" } Ernie