X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=doc%2Ffcgi-perl.htm;h=014c95356773ad08c5621887c12616e3f9ebbbd4;hb=bf00339bb4a4582979bfe26e714b9f1f6e8a0870;hp=058f10d34deb0e8e6706ad02fa0a8b62f43a1d20;hpb=0198fd3ca83ad0dbdb1c3bfb967d1843a7d02296;p=catagits%2Ffcgi2.git diff --git a/doc/fcgi-perl.htm b/doc/fcgi-perl.htm index 058f10d..014c953 100644 --- a/doc/fcgi-perl.htm +++ b/doc/fcgi-perl.htm @@ -6,8 +6,8 @@ vlink="#555555">
- - [[FastCGI]] + + [[FastCGI]]

Integrating FastCGI with Perl-5

@@ -21,7 +21,7 @@ Copyright © 1996 Open Market, Inc. 245 First Street, Cambridge, MA 02142 U.S.A.
Tel: 617-949-7000 URL: http://www.openmarket.com/
-$Id: fcgi-perl.htm,v 1.1 1997/09/16 15:36:26 stanleyg Exp $
+$Id: fcgi-perl.htm,v 1.2 2001/05/14 13:00:30 robs Exp $

@@ -50,7 +50,7 @@ FastCGI has been integrated with Perl in two different ways:
  • By writing a module that plugs into any Perl interpreter that's been built with FastCGI's fcgi_stdio library layering over stdio. - + The first approach, implemented by Sven Verdoolaege (skimo@breughel.ufsia.ac.be), is probably the better of the two, since sfio is a generally useful addition to Perl. @@ -171,7 +171,7 @@ will set your proper library path:
     % setenv PERL5LIB $INSTALL/lib:$INSTALL/lib/sun4-solaris/perl5.003_02
     
    - +

  • Obtain Perl/Sfio module for FastCGI support from @@ -228,8 +228,8 @@ There are good sources of information on Perl at:
  • http://www.perl.com/
  • http://www.metronet.com/perlinfo/ -

    - +

    +
  • Unpack the tar file in the parent directory of the FastCGI kit directory, so that the perl directory is a sibling of fcgi-devel-kit. $perl is used as shorthand for the full path of the directory @@ -335,7 +335,7 @@ You should specify the following ld flags: +>

    Additional Libraries:
    @@ -412,8 +412,8 @@ Pretty straightforward.

    [...] > make install - -

    + +

    3.3 Advanced recipe

    @@ -423,64 +423,44 @@ not really want to re-run Configure, you can take the following steps.

    THIS IS NOT RECOMMENDED

    Edit config.sh with your favorite editor and modify the following lines: -

    -
    cc
    -
    -Change to use gcc if you are not using it already. -
    -

    - -
    ccflags AND cppflags
    -
    -Add the following flags: -
      -
    • -I$fcgi/include -
    • -include $fcgi/include/fcgi_stdio.h -
    -This assumes you are using GCC. See the above section on assumptions -
    -

    - -
    extensions AND known_extensions
    -
    -Add FCGI to the list of extensions -
    -

    - -
    ldflags
    -
    -Add -L $fcgi/libfcgi to the list. -
    -

    - -
    libs
    -
    -Add -lfcgi to the list of libraries, should be added before -lc. -
    -

    -
    static_ext or dynamic_ext
    -
    -Add FCGI to the list of statically or dynamically loaded extensions. -
    -

    -
    d_stdio_cnt_lval, d_stdio_ptr_lval, d_stdiobase, d_stdstdio
    -
    -Change all of these to undef. -
    -

    -One you have edited config.sh you should do a "make Makefile depend all". -If you're paranoid like me you may want to do a "make clean" first. -

    - - -

    4. Writing FastCGI applications in Perl

    -

    -The Perl program examples/tiny-perl-fcgi performs the same function as -the C program examples/tiny-fcgi that's used as an example in the -FastCGI Developer's Kit document. -Here's what the Perl version looks like: -

    -
    +        
    +
    cc
    +
    Change to use gcc if you are not using it already.
    +

    +
    ccflags AND cppflags
    +
    Add the following flags: +
      +
    • -I$fcgi/include +
    • -include $fcgi/include/fcgi_stdio.h +
    + This assumes you are using GCC. See the above section on assumptions +
    +

    +
    extensions AND known_extensions
    +
    Add FCGI to the list of extensions
    +

    +
    ldflags
    +
    Add -L $fcgi/libfcgi to the list.
    +

    +
    libs
    +
    Add -lfcgi to the list of libraries, should be added before -lc. +
    +

    +
    static_ext or dynamic_ext
    +
    Add FCGI to the list of statically or dynamically loaded extensions. +
    +

    +
    d_stdio_cnt_lval, d_stdio_ptr_lval, d_stdiobase, d_stdstdio
    +
    Change all of these to undef.
    +

    One you have edited config.sh you should do a "make Makefile depend + all". If you're paranoid like me you may want to do a "make clean" + first.

    +

    4. Writing FastCGI applications in Perl

    +

    The Perl program examples/tiny-perl-fcgi performs the same + function as the C program examples/tiny-fcgi that's used + as an example in the FastCGI Developer's + Kit. Here's what the Perl version looks like:

    +
     #!./perl
     use FCGI;
     $count = 0;
    @@ -492,65 +472,54 @@ while(FCGI::accept() >= 0) {
               " running on host <i>$ENV('SERVER_NAME')</i>");
     }
     
    - -If you've built Perl according to the recipe and you have a Web server set -up to run FastCGI applications, load the FastCGI Developer's Kit Index Page -in that server and run this Perl application now.

    - -The script invokes Perl indirectly via the symbolic link -examples/perl. It does this because HP-UX has a limit of 32 -characters for the first line of a command-interpreter file such as -examples/tiny-perl-fcgi. If you run on HP-UX you won't want -to sprinkle symbolic links to perl everywhere, so you should -choose a PERL_PREFIX shorter than /usr/local/perl5-fcgi.

    - -You need to be aware of the following bug. If the -initial environment to a FastCGI Perl application is empty (contains -no name-value pairs) then when the first call to FCGI::accept -returns, the environment will still be empty, -i.e. %ENV will contain no associations. All the variables -associated with the first request are lost. There are two known -workarounds:

    - -

      -
    • - In your Perl application, enumerate %ENV using - each before entering the FCGI::accept - loop. The program examples/tiny-perl-fcgi - contains code for this.

      -

    • - In configuring your application be sure to set at least one - initial environment variable. You do this with the - AppClass -initial-env directive to the Web server, - or by running cgi-fcgi in a non-empty environment. -

    - -The Perl subroutine FCGI::accept treats the initial -environment differently than the C function FCGI_Accept. The -first call to the -C function FCGI_Accept replaces the initial environment with -the environment of the first request. The first call to the Perl subroutine -FCGI::accept adds the variable bindings of the first request -to the bindings present in the initial environment. So when the first -call to FCGI::accept returns, bindings from the initial -environment are still there (unless, due to naming conflicts, some of -them have been overwritten by the first request). The next call to -FCGI::accept removes the bindings made on the previous call -before adding a new set for the request just accepted, again preserving -the initial environment.

    - -The Perl FCGI module also includes -subroutines FCGI::finish, FCGI::set_exit_status, -and FCGI::start_filter_data that correspond to -C functions in fcgi_stdio.h; see the manpages for -full information.

    - -Converting a Perl CGI application to FastCGI is not fundamentally -different from converting a C CGI application. You separate -the portion of the application that performs one-time -initialization from the portion that performs per-request -processing. You put the per-request processing into a loop -controlled by FCGI::accept.

    - - + If you've built Perl according to the recipe and you have a Web server + set up to run FastCGI applications, load the FastCGI Developer's Kit + Index Page in that server and run this Perl application now. +

    The script invokes Perl indirectly via the symbolic link examples/perl. + It does this because HP-UX has a limit of 32 characters for the first + line of a command-interpreter file such as examples/tiny-perl-fcgi. + If you run on HP-UX you won't want to sprinkle symbolic links to perl + everywhere, so you should choose a PERL_PREFIX shorter than + /usr/local/perl5-fcgi. +

    You need to be aware of the following bug. If the initial environment + to a FastCGI Perl application is empty (contains no name-value pairs) + then when the first call to FCGI::accept returns, the environment + will still be empty, i.e. %ENV will contain no associations. + All the variables associated with the first request are lost. There + are two known workarounds: +

    +

      +
    • In your Perl application, enumerate %ENV using each + before entering the FCGI::accept loop. The program examples/tiny-perl-fcgi + contains code for this. +

      +

    • In configuring your application be sure to set at least one initial + environment variable. You do this with the AppClass -initial-env + directive to the Web server, or by running cgi-fcgi in + a non-empty environment. +
    +

    The Perl subroutine FCGI::accept treats the initial environment + differently than the C function FCGI_Accept. The first call + to the C function FCGI_Accept replaces the initial environment + with the environment of the first request. The first call to the Perl + subroutine FCGI::accept adds the variable bindings of the + first request to the bindings present in the initial environment. + So when the first call to FCGI::accept returns, bindings + from the initial environment are still there (unless, due to naming + conflicts, some of them have been overwritten by the first request). + The next call to FCGI::accept removes the bindings made on + the previous call before adding a new set for the request just accepted, + again preserving the initial environment. +

    The Perl FCGI module also includes subroutines FCGI::finish, + FCGI::set_exit_status, and FCGI::start_filter_data + that correspond to C functions in fcgi_stdio.h; see the manpages + for full information. +

    Converting a Perl CGI application to FastCGI is not fundamentally + different from converting a C CGI application. You separate the portion + of the application that performs one-time initialization from the + portion that performs per-request processing. You put the per-request + processing into a loop controlled by FCGI::accept. +

    +

    +