Writing Apache Modules with Perl and C

Book description

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 CGI.pm module. Doug is a consultant and the creator of the innovative mod_perl Apache module.

Table of contents

  1. Copyright
  2. Preface
    1. What You Need to Know to Get the Most out of This Book
    2. How This Book Is Organized
    3. Conventions
    4. The Companion Web Site to This Book
    5. Using FTP and CPAN
    6. Comments and Questions
    7. Acknowledgments
  3. Server-Side Programming with Apache
    1. Web Programming Then and Now
    2. The Apache Project
    3. The Apache C and Perl APIs
    4. Ideas and Success Stories
  4. A First Module
    1. Preliminaries
    2. Directory Layout Structure
    3. Installing mod_perl
    4. "Hello World" with the Perl API
    5. "Hello World" with the C API
    6. Instant Modules with Apache::Registry
    7. Troubleshooting Modules
  5. The Apache Module Architecture and API
    1. How Apache Works
    2. The Apache Life Cycle
    3. The Handler API
    4. Perl API Classes and Data Structures
  6. Content Handlers
    1. Content Handlers as File Processors
    2. Virtual Documents
    3. Redirection
    4. Processing Input
    5. Apache::Registry
    6. Handling Errors
    7. Chaining Content Handlers
    8. Method Handlers
  7. Maintaining State
    1. Choosing the Right Technique
    2. Maintaining State in Hidden Fields
    3. Maintaining State with Cookies
    4. Protecting Client-Side Information
    5. Storing State at the Server Side
    6. Storing State Information in SQL Databases
    7. Other Server-Side Techniques
  8. Authentication and Authorization
    1. Access Control, Authentication, and Authorization
    2. Access Control with mod_perl
    3. Authentication Handlers
    4. Authorization Handlers
    5. Cookie-Based Access Control
    6. Authentication with the Secure Sockets Layer
  9. Other Request Phases
    1. The Child Initialization and Exit Phases
    2. The Post Read Request Phase
    3. The URI Translation Phase
    4. The Header Parser Phase
    5. Customizing the Type Checking Phase
    6. Customizing the Fixup Phase
    7. The Logging Phase
    8. Registered Cleanups
    9. Handling Proxy Requests
    10. Perl Server-Side Includes
    11. Subclassing the Apache Class
  10. Customizing the Apache Configuration Process
    1. Simple Configuration with the PerlSetVar Directive
    2. The Apache Configuration Directive API
    3. Configuring Apache with Perl
    4. Documenting Configuration Files
  11. Perl API Reference Guide
    1. The Apache Request Object
    2. Other Core Perl API Classes
    3. Configuration Classes
    4. The Apache::File Class
    5. Special Global Variables, Subroutines, and Literals
  12. C API Reference Guide, Part I
    1. Which Header Files to Use?
    2. Major Data Structures
    3. Memory Management and Resource Pools
    4. The Array API
    5. The Table API
    6. Processing Requests
    7. Server Core Routines
  13. C API Reference Guide, Part II
    1. Implementing Configuration Directives in C
    2. Customizing the Configuration Process
    3. String and URI Manipulation
    4. File and Directory Management
    5. Time and Date Functions
    6. Message Digest Algorithm Functions
    7. User and Group ID Information Routines
    8. Data Mutex Locking
    9. Launching Subprocesses
  14. Standard Noncore Modules
    1. The Apache::Registry Class
    2. The Apache::PerlRun Class
    3. The Apache::RegistryLoader Class
    4. The Apache::Resource Class
    5. The Apache::PerlSections Class
    6. The Apache::ReadConfig Class
    7. The Apache::StatINC Class
    8. The Apache::Include Class
    9. The Apache::Status Class
  15. Building and Installing mod_perl
    1. Standard Installation
    2. Other Configuration Methods
  16. Building Multifule C API Modules
    1. Statistically Linked Modules That Need External Libraries
    2. Dynamically Linked Modules That Need External Libraries
    3. Building Modules from Several Source Files
  17. Apache:: Modules Available on CPAN
    1. Content Handling
    2. URI Translation
    3. Perl and HTML Mixing
    4. Authentication and Authorization
    5. Fixup
    6. Logging
    7. Profiling
    8. Persistent Database Connections
      1. Apache::DBI
      2. Apache::Mysql
      3. Apache::Sybase::CTlib
    9. Miscellaneous
    10. A
    11. A
    12. A
    13. A
    14. A
  18. Third-Party C Modules
    1. Content Handling
    2. International Language
    3. Security
    4. Access Control
    5. Authentication and Authorization
    6. Logging
    7. Distributed Authoring
    8. Miscellaneous
    9. M
    10. M
    11. M
    12. M
    13. M
    14. M
    15. M
    16. M
    17. L
  19. HTML::Embperl—Embedding Perl Code in HTML
    1. Dynamic Tables
    2. Handling Forms
    3. Storing Persistent Data
    4. Modularization of Embperl Pages
    5. Debugging
    6. Querying a Database
    7. Security
    8. An Extended Example
  20. Colophon
  21. Index

Product information

  • Title: Writing Apache Modules with Perl and C
  • Author(s): Doug MacEachern, Lincoln Stein
  • Release date: April 1999
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781565925670