On 2002.03.11, at 06:32, Bruce A. Burdick, Jr. wrote: > Thanks for the great suggestion. But in this case I'm trying to > install a > local working copy of a client's application that depends on FCGI.pm, > CGI::Fast.pm, and, of course, mod_fastcgi.
Out of curiosity I have tested FastCGI myself; I never had a chance to use it in details except when I installed on a FreeBSD box for one of my customers. I didn't even write a script for FastCGI myself. It turned out to be pretty easy. Here is the recipe I gathered. Precondition ------------ MacOS X version: 10.1.3 Apache Version: 1.3.22 (The one that comes with 10.1.3) Developer Kit installed (Required!) Build: mod_fcgi ---------------- You can use apxs so you don't have to build whole apache. 0. get http://www.fastcgi.com/dist/mod_fastcgi-2.2.12.tar.gz and untar the dist. on HFS+ volume 'tar zxf' may complain but you can happily ignore that. 1. build with apxs % apxs -o mod_fastcgi.so -c *.c when mod_fastcgi.so gets linked, cc complains like > /usr/bin/ld: warning unused multiple definitions of symbol _regerror > /usr/sbin/httpd definition of _regerror > /usr/lib/libSystem.dylib(regerror.o) unused definition of _regerror but your work directory should contain mod_fastcgi.so 2. Install the module % sudo apxs -i -a mod_fastcgi.so Build: FCGI.pm -------------- % wget http://www.cpan.org/authors/id/SKIMO/FCGI-0.65.tar.gz % tar zxf FCGI-0.65.tar.gz % cd FCGI-0.65 % perl Makefile.PL % make % sudo make install Configuration ------------- Since I only wanted a quick test, I made a configuration as follows; <IfModule mod_fastcgi.c> AddHandler fastcgi-script .fcgi </IfModule> Enjoy ----- And all you have to do is to (re)start apache. Note that you have to stop then start since you have added a new DSO. % apachectl configtest % sudo apachectl stop % sudo apachectl start I have also added a simple script which just shows you queries and envs (anologous to /Library/WebServer/CGI-Executables/printenv but based upon mod_perl-safe version) after the signature Foreword -------- I find mod_perl much easier to use and more versatile. Unlike FCGI which demands event loops, mod_perl's Apache::Registry lets you run most of the "well-behaved" CGI (that is, with taint checks and 'use strict') completely unmodified. mod_perl also appears faster (but I confess I have never stress tested FCGI). Well, FCGI has its strength, too. FCGI is not limited to perl but also for C, Phython and Ruby to name a few. Dan the Man with Too Many Modules Everywhere #!/usr/bin/perl use strict; use CGI::Fast; use File::Basename; my $Me = basename($0); my ($Queries, $Envs); while (my $q = new CGI::Fast){ my @k = $q->param; for my $k ( @k ){ my @v = $q->param($k); $Queries .= qq(<tr><th><tt>$k</tt></th>); if (@v){ my $ev = escape_string(join("¥n", @v)); $Queries .= qq(<td><pre>$ev</pre></td>); } $Queries .= "</tr>¥n"; } for my $k (sort keys %ENV){ my $ev = escape_string($ENV{$k}); $Envs .= qq(<tr><th><tt>$k</tt></th>); $ev and $Envs .= qq(<td><pre>$ev</pre></td>); $Envs .= "</tr>¥n"; } print <<"EOT"; Content-type: text/html <!doctype html public "-//W3C//DTD HTML 4.01 //EN"> <html> <head> <title>$Me</title> </Head> <body> <h1>$Me</h1> <H2>Queries</H2> <table border="1"> $Queries </table> <H2>Environment Variables</H2> <table border="1"> $Envs </table> </Html> EOT } sub escape_string{ my $str = shift; my %escape = ( '&' => 'amp', '<' => 'lt', '>' => 'gt', '¥"' => 'quot', ); $str =~ s/([<>&¥"])/'&' . $escape{$1} . ';'/eog; $str; } 1; __END__
