Cover image for Writing Apache modules with Perl and C
Writing Apache modules with Perl and C
Stein, Lincoln D., 1960-
Personal Author:
Publication Information:
Beijing ; Sebastopol, Calif. : O'Reilly, 1999.
Physical Description:
xix, 724 pages : illustrations ; 24 cm
General Note:
Includes "...a detachable modp̲erl quick reference card."--Cover.

Includes index.
Added Author:
Format :


Call Number
Material Type
Home Location
Item Holds
TK5105.8885.A63 S74 1999 Adult Non-Fiction Central Closed Stacks

On Order



Apache is the most popular web server on the Internet because it is free, reliable, and extensible. The availability of the source code and the modular design of Apache makes it possible to extend web server functionality through the Apache API.For the most part, however, the Apache API has only been available to C programmers, and requires rebuilding the Apache server from source. mod_perl, the popular Apache module used primarily for enhanced CGI performance, changed all that by making the Apache API available to Perl programmers. With mod_perl, it becomes simple to develop Apache modules with Perl and install them without having to rebuild the web server. Writing Apache Modules with Perl and C shows how to extend web server capabilities regardless of whether the programming language is Perl or C. The book explains the design of Apache, mod_perl, and the Apache API. It then demonstrates how to use them to perform for tasks like the following:

Rewriting CGI scripts as Apache modules to vastly improve performance Server-side filtering of HTML documents, to embed special markup or code (much like SSI) Enhancing server log functionality Converting file formats on the fly Implementing dynamic navigation bars Incorporating database access into CGI scripts Customizing access control and authorization to block robots or to use an external database for passwords The authors are Lincoln Stein and Doug MacEachern. Lincoln is the successful author of How to Set Up and Maintain a World Wide web Site and the developer of the widely used Perl module. Doug is a consultant and the creator of the innovative mod_perl Apache module.

Author Notes

Doug MacEachern has been addicted to Perl and web servers since early 1994 when he was introduced to Plexus as a student employee at the University of Arizona. Soon after returning to his home town of Boston, Massachusetts, and entering the "real world," he discovered the Apache web server, and since early 1996, he has been gluing Perl into all its nooks and crannies. His day job has consisted of integrating various other technologies with the Web, including DCE, Kerberos, and GSSAPI, but Perl has been the only one he cannot let go of. Doug has continued as a developer disguised as a consultant since the start of 1998, spending most of his time between Auckland, New Zealand, and San Francisco, California, with time at home in Boston during the warmer months. Doug likes to spend his time away from software--far, far away, sailing on the ocean, diving below it, or simply looking at it from a warm, sandy beach where technology doesn't go much beyond thatched huts and blenders.

Lincoln Stein is an assistant investigator at Cold Spring Harbor Laboratory, where he develops databases and user interfaces for the Human Genome Project using the Apache server and its module API. He is the author of several books about programming for the Web, including The Official Guide to, How to Set Up and Maintain a Web Site, and Web Security: A Step-by-Step Reference Guide.

Table of Contents

1 Server-Side Programming with Apache Web Programming Then and Now The Apache Project
The Apache C and Perl APIs Ideas and Success Stories
2 A First Module Preliminaries Directory Layout Structure Installing mod_perl "Hello World" with the Perl API "Hello World" with the C API Instant Modules with Apache::Registry Troubleshooting Modules
3 The Apache Module Architecture and API How Apache Works
The Apache Life Cycle
The Handler API Perl API Classes and Data Structures
4 Content Handlers Content Handlers as File Processors Virtual Documents Redirection Processing Input Apache::Registry Handling Errors Chaining Content Handlers Method Handlers
5 Maintaining State Choosing the Right Technique Maintaining State in Hidden Fields Maintaining State with Cookies Protecting Client-Side
Information Storing State at the Server Side Storing State Information in SQL Databases Other Server-Side Techniques
6 Authentication and Authorization Access Control, Authentication, and Authorization Access Control with mod_perl Authentication Handlers Authorization Handlers Cookie-Based Access Control Authentication with the Secure Sockets Layer
7 Other Request Phases
The Child Initialization and Exit Phases
The Post Read Request Phase
The URI Translation Phase
The Header Parser Phase Customizing the Type Checking Phase Customizing the Fixup Phase
The Logging Phase Registered Cleanups Handling Proxy Requests Perl Server-Side Includes Subclassing the Apache Class
8 Customizing the Apache Configuration Process Simple Configuration with the PerlSetVar Directive
The Apache Configuration Directive API Configuring Apache with Perl Documenting Configuration Files
9 Perl API Reference Guide
The Apache Request Object Other Core Perl API Classes Configuration Classes
The Apache::File Class Special Global Variables, Subroutines, and Literals
10 C API Reference Guide, Part I Which Header Files to Use? Major Data Structures Memory Management and Resource Pools
The Array API
The Table API Processing Requests Server Core Routines
11 C API Reference Guide, Part II Implementing Configuration Directives in C Customizing the Configuration Process String and URI Manipulation File and Directory Management Time and Date Functions Message Digest Algorithm Functions User and Group ID Information Routines Data Mutex Locking Launching Subprocesses
A Standard Noncore Modules
B Building and Installing mod_perl
C Building Multifile C API Modules
D Apache:: Modules Available on CPAN E. Third-Party C Modules F. HTML::Embperl-Embedding Perl Code in HTML