Preface
Part I. mod_perl Administration
1. Introducing CGI and mod_perl
A Brief History of CGI
The Apache 1.3 Server Model
The Development of mod_perl 1.0
Apache 1.3 Request Processing Phases
References
2. Getting Started Fast
Installing mod_perl 1.0 in Three Steps
Installing mod_perl on Unix Platforms
Configuring and Starting the mod_perl Server
Installing mod_perl for Windows
Preparing the Scripts Directory
A Sample Apache::Registry Script
A Simple mod_perl Content Handler
Is This All We Need to Know About mod_perl?
References
3. Installing mod_perl
Configuring the Source
Building mod_perl (make)
Testing the Server (make test)
Installation (make install)
Installation Scenarios for Standalone mod_perl
Building mod_perl with Other Components
Installing mod_perl with the CPAN.pm Interactive Shell
Installing mod_perl on Multiple Machines
Installation into a Nonstandard Directory
How Can I Tell if mod_perl Is Running?
General Notes
References
4. mod_perl Configuration
Apache Configuration
mod_perl Configuration
The Startup File
Apache Configuration in Perl
Validating the Configuration Syntax
The Scope of mod_perl Configuration Directives
Apache Restarts Twice
Enabling Remote Server Configuration Reports
Tips and Tricks
Configuration Security Concerns
General Pitfalls
References
5. Web Server Control, Monitoring, Upgrade, and Maintenance
Starting the Server in Multi-Process Mode
Starting the Server in Single-Process Mode
Using kill to Control Processes
Using apachectl to Control the Server
Validating Server Configuration
Setuid root Startup Scripts
Preparing for Machine Reboot
Upgrading a Live Server
Three-Tier Server Scheme: Development, Staging, and Production
Web Server Monitoring
Server Maintenance Chores
References
6. Coding with mod_perl in Mind
Before You Start to Code
Exposing Apache::Registry Secrets
Namespace Issues
Perl Specifics in the mod_perl Environment
CHECK and INIT Blocks
Apache::Registry Specifics
Transition from mod_cgi Scripts to Apache Handlers
Loading and Reloading Modules
Handling the "User Pressed Stop Button" Case
Handling Server Timeout Cases and Working with $SIG{ALRM}
Generating Correct HTTP Headers
Method Handlers: The Browse and See, Browse and View Example
References
Part II. mod_perl Performance
7. Identifying Your Performance Problems
Looking at the Big Picture
Asking the Right Questions
References
8. Choosing a Platform for the Best Performance
Choosing the Right Operating System
Choosing the Right Hardware
References
9. Essential Tools for Performance Tuning
Server Benchmarking
Perl Code Benchmarking
Process Memory Measurements
Apache::Status and Measuring Code Memory Usage
Code Profiling Techniques
References
10. Improving Performance with Shared Memory and Proper Forking
Sharing Memory
Forking and Executing Subprocesses from mod_perl
References
11. Tuning Performance by Tweaking Apache's Configuration
Setting the MaxClients Directive
Setting the MaxRequestsPerChild Directive
Setting MinSpareServers, MaxSpareServers, and StartServers
KeepAlive
PerlSetupEnv
Reducing the Number of stat( ) Calls Made by Apache
Symbolic Links Lookup
Disabling DNS Resolution
Response Compressing
References
12. Server Setup Strategies
mod_perl Deployment Overview
Standalone mod_perl-Enabled Apache Server
One Plain and One mod_perl-Enabled Apache Server
One Light Non-Apache and One mod_perl-Enabled Apache Server
Adding a Proxy Server in httpd Accelerator Mode
The Squid Server and mod_perl
Apache's mod_proxy Module
mod_rewrite Examples
Getting the Remote Server IP in the Backend Server in the Proxy Setup
Frontend/Backend Proxying with Virtual Hosts
HTTP Authentication with Two Servers and a Proxy
When One Machine Is Not Enough for Your RDBMS DataBase and mod_perl
Running More than One mod_perl Server on the Same Machine
SSL Functionality and a mod_perl Server
Uploading and Downloading Big Files
References
13. TMTOWTDI: Convenience and Habit Versus Performance
Apache::Registry PerlHandler Versus Custom PerlHandle
Apache::args Versus Apache::Request::param Versus CGI::param
Buffered Printing and Better print( ) Techniques
Interpolation, Concatenation, or List
Keeping a Small Memory Footprint
Object Methods Calls Versus Function Calls
Using the Perl stat( ) Call's Cached Results
time( ) System Call Versus $r->request_time
Printing Unmodified Files
Caching and Pre-Caching
Caching with Memoize
Comparing Runtime Performance of Perl and C
References
14. Defensive Measures for Performance Enhancement
Controlling Your Memory Usage
Coding for a Smaller Memory Footprint
Conclusion
References
15. Improving Performance Through Build Options
Server Size as a Function of Compiled-in Features
mod_status and ExtendedStatus On
DYNAMIC_MODULE_LIMIT Apache Build Option
Perl Build Options
Architecture-Specific Compile Options
References
16. HTTP Headers for Optimal Performance
Date-Related Headers
Content Headers
Content Negotiation
HTTP Requests
Avoiding Dealing with Headers
References
Part III. Databases and mod_perl
17. Databases Overview
Volatile Databases
Non-Volatile Databases
References
18. mod_perl Data-Sharing Techniques
Sharing the Read-Only Data in and Between Processes
Sharing Data Between Various Handlers
References
19. DBM and mod_perl
mod_perl and DBM
Resource Locking
Flawed Locking Methods
Locking Wrappers Overview
Tie::DB_Lock
Examples
References
20. Relational Databases and mod_perl
Persistent Database Connections with Apache::DBI
Improving Performance
DBI Debug Techniques
References
Part IV. Debugging and Troubleshooting
21. Error Handling and Debugging
Warnings and Errors Explained
Debugging Code in Single-Server Mode
Tracing System Calls
Tracing mod_perl-Specific Perl Calls
Debugging Perl Code
Analyzing Dumped core Files
Hanging Processes: Detection and Diagnostics
Useful Debug Modules
Looking Inside the Server
References
22. Troubleshooting mod_perl
Configuration and Startup
Code Parsing and Compilation
Runtime
Shutdown and Restart
23. Getting Help and Online Resources
How to Report Problems
Mailing List Etiquette
Resources
Part V. mod_perl 2.0
24. mod_perl 2.0: Installation and Configuration
What's New in Apache 2.0
What's New in Perl 5.6.0-5.8.0
What's New in mod_perl 2.0
Installing mod_perl 2.0
Configuring mod_perl 2.0
Resources
25. Programming for mod_perl 2.0
Migrating to and Programming with mod_perl 2.0
New Apache Phases and Corresponding Perl*Handlers
I/O Filtering
Part VI. Appendixes
A. mod_perl Recipes
Emulating the Authentication Mechanism
Reusing Data from POST Requests
Redirecting POST Requests
Redirecting While Maintaining Environment Variables
Handling Cookies
Sending Multiple Cookies with the mod_perl API
Sending Cookies in REDIRECT Responses
CGI::params in the mod_perlish Way
Sending Email from mod_perl
mod_rewrite in Perl
Setting PerlHandler Based on MIME Type
Singleton Database Handles
Terminating a Child Process on Request Completion
References
B. Apache Perl Modules
Development-Stage Modules
Modules to Aid Debugging
Control and Monitoring Modules
Server Configuration Modules
Authentication-Phase Modules
Authorization-Phase Modules
Access-Phase Modules
Type Handlers
Trans Handlers
Fixup Handlers
Generic Content-Generation Modules
Application-Specific Content-Generation Modules
Database Modules
Toolkits and Frameworks for Content-Generation and Other Phases
Output Filters and Layering Modules
Logging-Phase Handlers
Core Apache Modules
Other Miscellaneous Modules
C. ISPs Providing mod_perl Services
Users Sharing a Single Web Server
Users Sharing a Single Machine
Giving Each User a Separate Machine (Colocation)
Giving Each User a Virtual Machine
D. The Template Toolkit
Fetching and Installing the Template Toolkit
Overview
Typical Uses
Template Toolkit Language
Processing Templates
Apache/mod_perl Handler
Apache::Template Module
Hangman Application
References
E. The AxKit XML Application Server
Installing and Configuring AxKit
Your First AxKit Page
Dynamic Content
More XPathScript Details
XSLT
Putting Everything Together
More Reasons to Use AxKit
F. HTTP Status Codes
HTTP/1.0 Status Codes
HTTP/1.1 Status Codes
References
Index