|
|
Copyright |
|
|
Preface |
|
|
|
What You Need to Know |
|
|
|
Who This Book Is For |
|
|
|
How This Book Is Organized |
|
|
|
Reference Sections |
|
|
|
Filesystem Conventions |
|
|
|
Apache and Perl Versions |
|
|
|
Typographic Conventions |
|
|
|
Command Interpreter Program (Shell) Conventions |
|
|
|
Installing Perl Modules |
|
|
|
How to Contact Us |
|
|
|
Acknowledgments |
|
|
|
Part I:
mod_perl Administration |
|
|
|
Chapter 1.
Introducing CGI and mod_perl |
|
|
|
Section 1.1.
A Brief History of CGI |
|
|
|
Section 1.2.
The Apache 1.3 Server Model |
|
|
|
Section 1.3.
The Development of mod_perl 1.0 |
|
|
|
Section 1.4.
Apache 1.3 Request Processing Phases |
|
|
|
Section 1.5.
References |
|
|
|
|
Chapter 2.
Getting Started Fast |
|
|
|
Section 2.1.
Installing mod_perl 1.0 in Three Steps |
|
|
|
Section 2.2.
Installing mod_perl on Unix Platforms |
|
|
|
Section 2.3.
Configuring and Starting the mod_perl Server |
|
|
|
Section 2.4.
Installing mod_perl for Windows |
|
|
|
Section 2.5.
Preparing the Scripts Directory |
|
|
|
Section 2.6.
A Sample Apache::Registry Script |
|
|
|
Section 2.7.
A Simple mod_perl Content Handler |
|
|
|
Section 2.8.
Is This All We Need to Know About mod_perl? |
|
|
|
Section 2.9.
References |
|
|
|
|
Chapter 3.
Installing mod_perl |
|
|
|
Section 3.1.
Configuring the Source |
|
|
|
Section 3.2.
Building mod_perl (make) |
|
|
|
Section 3.3.
Testing the Server (make test) |
|
|
|
Section 3.4.
Installation (make install) |
|
|
|
Section 3.5.
Installation Scenarios for Standalone mod_perl |
|
|
|
Section 3.6.
Building mod_perl with Other Components |
|
|
|
Section 3.7.
Installing mod_perl with the CPAN.pm Interactive Shell |
|
|
|
Section 3.8.
Installing mod_perl on Multiple Machines |
|
|
|
Section 3.9.
Installation into a Nonstandard Directory |
|
|
|
Section 3.10.
How Can I Tell if mod_perl Is Running? |
|
|
|
Section 3.11.
General Notes |
|
|
|
Section 3.12.
References |
|
|
|
|
Chapter 4.
mod_perl Configuration |
|
|
|
Section 4.1.
Apache Configuration |
|
|
|
Section 4.2.
mod_perl Configuration |
|
|
|
Section 4.3.
The Startup File |
|
|
|
Section 4.4.
Apache Configuration in Perl |
|
|
|
Section 4.5.
Validating the Configuration Syntax |
|
|
|
Section 4.6.
The Scope of mod_perl Configuration Directives |
|
|
|
Section 4.7.
Apache Restarts Twice |
|
|
|
Section 4.8.
Enabling Remote Server Configuration Reports |
|
|
|
Section 4.9.
Tips and Tricks |
|
|
|
Section 4.10.
Configuration Security Concerns |
|
|
|
Section 4.11.
General Pitfalls |
|
|
|
Section 4.12.
References |
|
|
|
|
Chapter 5.
Web Server Control, Monitoring, Upgrade, and Maintenance |
|
|
|
Section 5.1.
Starting the Server in Multi-Process Mode |
|
|
|
Section 5.2.
Starting the Server in Single-Process Mode |
|
|
|
Section 5.3.
Using kill to Control Processes |
|
|
|
Section 5.4.
Using apachectl to Control the Server |
|
|
|
Section 5.5.
Validating Server Configuration |
|
|
|
Section 5.6.
Setuid root Startup Scripts |
|
|
|
Section 5.7.
Preparing for Machine Reboot |
|
|
|
Section 5.8.
Upgrading a Live Server |
|
|
|
Section 5.9.
Three-Tier Server Scheme: Development, Staging, and Production |
|
|
|
Section 5.10.
Web Server Monitoring |
|
|
|
Section 5.11.
Server Maintenance Chores |
|
|
|
Section 5.12.
References |
|
|
|
|
Chapter 6.
Coding with mod_perl in Mind |
|
|
|
Section 6.1.
Before You Start to Code |
|
|
|
Section 6.2.
Exposing Apache::Registry Secrets |
|
|
|
Section 6.3.
Namespace Issues |
|
|
|
Section 6.4.
Perl Specifics in the mod_perl Environment |
|
|
|
Section 6.5.
CHECK and INIT Blocks |
|
|
|
Section 6.6.
Apache::Registry Specifics |
|
|
|
Section 6.7.
Transition from mod_cgi Scripts to Apache Handlers |
|
|
|
Section 6.8.
Loading and Reloading Modules |
|
|
|
Section 6.9.
Handling the "User Pressed Stop Button" Case |
|
|
|
Section 6.10.
Handling Server Timeout Cases and Working with $SIG{ALRM} |
|
|
|
Section 6.11.
Generating Correct HTTP Headers |
|
|
|
Section 6.12.
Method Handlers: The Browse and See, Browse and View Example |
|
|
|
Section 6.13.
References |
|
|
|
|
Part II:
mod_perl Performance |
|
|
|
Chapter 7.
Identifying Your Performance Problems |
|
|
|
Section 7.1.
Looking at the Big Picture |
|
|
|
Section 7.2.
Asking the Right Questions |
|
|
|
Section 7.3.
References |
|
|
|
|
Chapter 8.
Choosing a Platform for the Best Performance |
|
|
|
Section 8.1.
Choosing the Right Operating System |
|
|
|
Section 8.2.
Choosing the Right Hardware |
|
|
|
Section 8.3.
References |
|
|
|
|
Chapter 9.
Essential Tools for Performance Tuning |
|
|
|
Section 9.1.
Server Benchmarking |
|
|
|
Section 9.2.
Perl Code Benchmarking |
|
|
|
Section 9.3.
Process Memory Measurements |
|
|
|
Section 9.4.
Apache::Status and Measuring Code Memory Usage |
|
|
|
Section 9.5.
Code Profiling Techniques |
|
|
|
Section 9.6.
References |
|
|
|
|
Chapter 10.
Improving Performance with Shared Memory and Proper Forking |
|
|
|
Section 10.1.
Sharing Memory |
|
|
|
Section 10.2.
Forking and Executing Subprocessesfrom mod_perl |
|
|
|
Section 10.3.
References |
|
|
|
|
Chapter 11.
Tuning Performance by Tweaking Apache's Configuration |
|
|
|
Section 11.1.
Setting the MaxClients Directive |
|
|
|
Section 11.2.
Setting the MaxRequestsPerChild Directive |
|
|
|
Section 11.3.
Setting MinSpareServers, MaxSpareServers, and StartServers |
|
|
|
Section 11.4.
KeepAlive |
|
|
|
Section 11.5.
PerlSetupEnv |
|
|
|
Section 11.6.
Reducing the Number of stat( ) Calls Made by Apache |
|
|
|
Section 11.7.
Symbolic Links Lookup |
|
|
|
Section 11.8.
Disabling DNS Resolution |
|
|
|
Section 11.9.
Response Compressing |
|
|
|
Section 11.10.
References |
|
|
|
|
Chapter 12.
Server Setup Strategies |
|
|
|
Section 12.1.
mod_perl Deployment Overview |
|
|
|
Section 12.2.
Standalone mod_perl-Enabled Apache Server |
|
|
|
Section 12.3.
One Plain and One mod_perl-Enabled Apache Server |
|
|
|
Section 12.4.
One Light Non-Apache and One mod_perl-Enabled Apache Server |
|
|
|
Section 12.5.
Adding a Proxy Server in httpd Accelerator Mode |
|
|
|
Section 12.6.
The Squid Server and mod_perl |
|
|
|
Section 12.7.
Apache's mod_proxy Module |
|
|
|
Section 12.8.
mod_rewrite Examples |
|
|
|
Section 12.9.
Getting the Remote Server IP in the Backend Server in the Proxy Setup |
|
|
|
Section 12.10.
Frontend/Backend Proxying with Virtual Hosts |
|
|
|
Section 12.11.
HTTP Authentication with Two Servers and a Proxy |
|
|
|
Section 12.12.
When One Machine Is Not Enough for Your RDBMS DataBase and mod_perl |
|
|
|
Section 12.13.
Running More than One mod_perl Server on the Same Machine |
|
|
|
Section 12.14.
SSL Functionality and a mod_perl Server |
|
|
|
Section 12.15.
Uploading and Downloading Big Files |
|
|
|
Section 12.16.
References |
|
|
|
|
Chapter 13.
TMTOWTDI: Convenience and Habit Versus Performance |
|
|
|
Section 13.1.
Apache::Registry PerlHandler Versus Custom PerlHandler |
|
|
|
Section 13.2.
Apache::args Versus Apache::Request::param Versus CGI::param |
|
|
|
Section 13.3.
Buffered Printing and Better print( ) Techniques |
|
|
|
Section 13.4.
Interpolation, Concatenation, or List |
|
|
|
Section 13.5.
Keeping a Small Memory Footprint |
|
|
|
Section 13.6.
Object Methods Calls Versus Function Calls |
|
|
|
Section 13.7.
Using the Perl stat( ) Call's Cached Results |
|
|
|
Section 13.8.
time( ) System Call Versus $r->request_time |
|
|
|
Section 13.9.
Printing Unmodified Files |
|
|
|
Section 13.10.
Caching and Pre-Caching |
|
|
|
Section 13.11.
Caching with Memoize |
|
|
|
Section 13.12.
Comparing Runtime Performance of Perl and C |
|
|
|
Section 13.13.
References |
|
|
|
|
Chapter 14.
Defensive Measures for Performance Enhancement |
|
|
|
Section 14.1.
Controlling Your Memory Usage |
|
|
|
Section 14.2.
Coding for a Smaller Memory Footprint |
|
|
|
Section 14.3.
Conclusion |
|
|
|
Section 14.4.
References |
|
|
|
|
Chapter 15.
Improving Performance Through Build Options |
|
|
|
Section 15.1.
Server Size as a Function of Compiled-in Features |
|
|
|
Section 15.2.
mod_status and ExtendedStatus On |
|
|
|
Section 15.3.
DYNAMIC_MODULE_LIMIT Apache Build Option |
|
|
|
Section 15.4.
Perl Build Options |
|
|
|
Section 15.5.
Architecture-Specific Compile Options |
|
|
|
Section 15.6.
References |
|
|
|
|
Chapter 16.
HTTP Headers for Optimal Performance |
|
|
|
Section 16.1.
Date-Related Headers |
|
|
|
Section 16.2.
Content Headers |
|
|
|
Section 16.3.
Content Negotiation |
|
|
|
Section 16.4.
HTTP Requests |
|
|
|
Section 16.5.
Avoiding Dealing with Headers |
|
|
|
Section 16.6.
References |
|
|
|
|
Part III:
Databases and mod_perl |
|
|
|
Chapter 17.
Databases Overview |
|
|
|
Section 17.1.
Volatile Databases |
|
|
|
Section 17.2.
Non-Volatile Databases |
|
|
|
Section 17.3.
References |
|
|
|
|
Chapter 18.
mod_perl Data-Sharing Techniques |
|
|
|
Section 18.1.
Sharing the Read-Only Data in and Between Processes |
|
|
|
Section 18.2.
Sharing Data Between Various Handlers |
|
|
|
Section 18.3.
References |
|
|
|
|
Chapter 19.
DBM and mod_perl |
|
|
|
Section 19.1.
mod_perl and DBM |
|
|
|
Section 19.2.
Resource Locking |
|
|
|
Section 19.3.
Flawed Locking Methods |
|
|
|
Section 19.4.
Locking Wrappers Overview |
|
|
|
Section 19.5.
Tie::DB_Lock |
|
|
|
Section 19.6.
Examples |
|
|
|
Section 19.7.
References |
|
|
|
|
Chapter 20.
Relational Databases and mod_perl |
|
|
|
Section 20.1.
Persistent Database Connections with Apache::DBI |
|
|
|
Section 20.2.
Improving Performance |
|
|
|
Section 20.3.
DBI Debug Techniques |
|
|
|
Section 20.4.
References |
|
|
|
|
Part IV:
Debugging and Troubleshooting |
|
|
|
Chapter 21.
Error Handling and Debugging |
|
|
|
Section 21.1.
Warnings and Errors Explained |
|
|
|
Section 21.2.
Debugging Code in Single-Server Mode |
|
|
|
Section 21.3.
Tracing System Calls |
|
|
|
Section 21.4.
Tracing mod_perl-Specific Perl Calls |
|
|
|
Section 21.5.
Debugging Perl Code |
|
|
|
Section 21.6.
Analyzing Dumped core Files |
|
|
|
Section 21.7.
Hanging Processes: Detection and Diagnostics |
|
|
|
Section 21.8.
Useful Debug Modules |
|
|
|
Section 21.9.
Looking Inside the Server |
|
|
|
Section 21.10.
References |
|
|
|
|
Chapter 22.
Troubleshooting mod_perl |
|
|
|
Section 22.1.
Configuration and Startup |
|
|
|
Section 22.2.
Code Parsing and Compilation |
|
|
|
Section 22.3.
Runtime |
|
|
|
Section 22.4.
Shutdown and Restart |
|
|
|
|
Chapter 23.
Getting Help and Online Resources |
|
|
|
Section 23.1.
How to Report Problems |
|
|
|
Section 23.2.
Mailing List Etiquette |
|
|
|
Section 23.3.
Resources |
|
|
|
|
Part V:
mod_perl 2.0 |
|
|
|
Chapter 24.
mod_perl 2.0: Installation and Configuration |
|
|
|
Section 24.1.
What's New in Apache 2.0 |
|
|
|
Section 24.2.
What's New in Perl 5.6.0-5.8.0 |
|
|
|
Section 24.3.
What's New in mod_perl 2.0 |
|
|
|
Section 24.4.
Installing mod_perl 2.0 |
|
|
|
Section 24.5.
Configuring mod_perl 2.0 |
|
|
|
Section 24.6.
Resources |
|
|
|
|
Chapter 25.
Programming for mod_perl 2.0 |
|
|
|
Section 25.1.
Migrating to and Programming with mod_perl 2.0 |
|
|
|
Section 25.2.
New Apache Phases and Corresponding Perl*Handlers |
|
|
|
Section 25.3.
I/O Filtering |
|
|
|
|
Part VI:
Appendixes |
|
|
|
Appendix A.
mod_perl Recipes |
|
|
|
Section A.1.
Emulating the Authentication Mechanism |
|
|
|
Section A.2.
Reusing Data from POST Requests |
|
|
|
Section A.3.
Redirecting POST Requests |
|
|
|
Section A.4.
Redirecting While Maintaining Environment Variables |
|
|
|
Section A.5.
Handling Cookies |
|
|
|
Section A.6.
Sending Multiple Cookies with the mod_perl API |
|
|
|
Section A.7.
Sending Cookies in REDIRECT Responses |
|
|
|
Section A.8.
CGI::params in the mod_perlish Way |
|
|
|
Section A.9.
Sending Email from mod_perl |
|
|
|
Section A.10.
mod_rewrite in Perl |
|
|
|
Section A.11.
Setting PerlHandler Based on MIME Type |
|
|
|
Section A.12.
Singleton Database Handles |
|
|
|
Section A.13.
Terminating a Child Process on Request Completion |
|
|
|
Section A.14.
References |
|
|
|
|
Appendix B.
Apache Perl Modules |
|
|
|
Section B.1.
Development-Stage Modules |
|
|
|
Section B.2.
Modules to Aid Debugging |
|
|
|
Section B.3.
Control and Monitoring Modules |
|
|
|
Section B.4.
Server Configuration Modules |
|
|
|
Section B.5.
Authentication-Phase Modules |
|
|
|
Section B.6.
Authorization-Phase Modules |
|
|
|
Section B.7.
Access-Phase Modules |
|
|
|
Section B.8.
Type Handlers |
|
|
|
Section B.9.
Trans Handlers |
|
|
|
Section B.10.
Fixup Handlers |
|
|
|
Section B.11.
Generic Content-Generation Modules |
|
|
|
Section B.12.
Application-Specific Content-Generation Modules |
|
|
|
Section B.13.
Database Modules |
|
|
|
Section B.14.
Toolkits and Frameworks for Content-Generation and Other Phases |
|
|
|
Section B.15.
Output Filters and Layering Modules |
|
|
|
Section B.16.
Logging-Phase Handlers |
|
|
|
Section B.17.
Core Apache Modules |
|
|
|
Section B.18.
Other Miscellaneous Modules |
|
|
|
|
Appendix C.
ISPs Providing mod_perl Services |
|
|
|
Section C.1.
Users Sharing a Single Web Server |
|
|
|
Section C.2.
Users Sharing a Single Machine |
|
|
|
Section C.3.
Giving Each User a Separate Machine (Colocation) |
|
|
|
Section C.4.
Giving Each User a Virtual Machine |
|
|
|
|
Appendix D.
The Template Toolkit |
|
|
|
Section D.1.
Fetching and Installing the Template Toolkit |
|
|
|
Section D.2.
Overview |
|
|
|
Section D.3.
Typical Uses |
|
|
|
Section D.4.
Template Toolkit Language |
|
|
|
Section D.5.
Processing Templates |
|
|
|
Section D.6.
Apache/mod_perl Handler |
|
|
|
Section D.7.
Apache::Template Module |
|
|
|
Section D.8.
Hangman Application |
|
|
|
Section D.9.
References |
|
|
|
|
Appendix E.
The AxKit XML Application Server |
|
|
|
Section E.1.
Installing and Configuring AxKit |
|
|
|
Section E.2.
Your First AxKit Page |
|
|
|
Section E.3.
Dynamic Content |
|
|
|
Section E.4.
More XPathScript Details |
|
|
|
Section E.5.
XSLT |
|
|
|
Section E.6.
Putting Everything Together |
|
|
|
Section E.7.
More Reasons to Use AxKit |
|
|
|
|
Appendix F.
HTTP Status Codes |
|
|
|
Section F.1.
HTTP/1.0 Status Codes |
|
|
|
Section F.2.
HTTP/1.1 Status Codes |
|
|
|
Section F.3.
References |
|
|
|
|
Colophon |
|
|
Index |