[Nitro] Nitro Apache2 CGI/FCGI (again)

Erik Howard erik at kommunicate.net
Thu Dec 29 14:49:21 EST 2005

Kashia Buch wrote:

>On Thu, 29 Dec 2005 20:01:03 +0100, Erik Howard <erik at kommunicate.net>  
>>RewriteRule ^(.*)$ *fcgi.rb* [QSA,L]
>This produces exactly the same error.
Here's the revelant bits i have in my httpd.conf file


LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so

User apacheuser
Group apachegroup

# Important. The following directives come *after*
# User and Group
FastCgiIpcDir /var/tmp/fcgi
FastCgiConfig -initial-env 'RUBYOPT=-rubygems

AddHandler fastcgi-script fcgi fpl rb

# No peeking at my .htaccess files
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName exaple.com
  ServerAlias www.example.com
  DocumentRoot /path/to/docroot

  <Directory "/path/to/docroot">
      Options FollowSymLinks +ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all



RewriteEngine On
RewriteRule ^/$ /index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /fcgi.rb [QSA,L]

To test if you have FastCGI working correctly, you can try the following 
script. Dont forget to make the script executable.


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

def print_env(title,env)
   str = "#{title}:<br>\n<pre>\n"
   env.each do |k,v|
   str<< "</pre><p>\n"

count = 0
FCGI.each_cgi do |cgi|
   count += 1
   content = "<title>FastCGI echo</title><h1>FastCGI echo</h1>\n"
   content<< sprintf("Request number %d,  Process ID: %d<p>\n", count, 
   content<< print_env("Request environment", cgi.env_table)

More information about the Nitro-general mailing list