Stas Bekman > DocSet-0.19 > Introduction

Download:
DocSet-0.19.tar.gz

Annotate this POD

View/Report Bugs
Source  

NAME ^

Introduction and Incentives

Description ^

An introduction to what mod_perl is all about, its different features, and some explanations of the C API, Apache::Registry, Apache::PerlRun and the Apache/Perl API.

What is mod_perl? ^

The Apache/Perl integration project brings together the full power of the Perl programming language and the Apache HTTP server. With mod_perl it is possible to write Apache modules entirely in Perl, letting you easily do things that are more difficult or impossible in regular CGI programs, such as running sub requests. In addition, the persistent Perl interpreter embedded in the server saves the overhead of starting an external interpreter, i.e. the penalty of Perl start-up time. And not the least important feature is code caching, where modules and scripts are loaded and compiled only once, and for the rest of the server's life they are served from the cache. Thus the server spends its time only running already loaded and compiled code, which is very fast.

The primary advantages of mod_perl are power and speed. You have full access to the inner workings of the web server and can intervene at any stage of request-processing. This allows for customized processing of (to name just a few of the phases) URI->filename translation, authentication, response generation, and logging. There is very little run-time overhead. In particular, it is not necessary to start a separate process, as is often done with web-server extensions. The most wide-spread such extension, the Common Gateway Interface (CGI), can be replaced entirely with Perl code that handles the response generation phase of request processing. mod_perl includes two general purpose modules for this purpose: Apache::Registry, which can transparently run existing perl CGI scripts and Apache::PerlRun, which does a similar job but allows you to run "dirtier" (to some extent) scripts.

You can configure your httpd server and handlers in Perl (using PerlSetVar, and <Perl> sections). You can even define your own configuration directives.

For examples on how you use mod_perl, see our What is mod_perl? section.

Many people ask "How much of a performance improvement does mod_perl give?" Well, it all depends on what you are doing with mod_perl and possibly who you ask. Developers report speed boosts from 200% to 2000%. The best way to measure is to try it and see for yourself! (See Technologie Extraordinaire for the facts.)

mod_cgi

When you run your CGI scripts by using a configuration like this:

  ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/

you run it under a mod_cgi handler, you never define it explicitly. Apache does all the configuration work behind the scenes, when you use a ScriptAlias.

By the way, don't confuse ScriptAlias with the ExecCGI configuration option, which we enable so that the script will be executed rather than returned as a plain text file. For example for mod_perl and Apache::Registry you would use a configuration like:

  <Location /perl>
    SetHandler perl-script
    PerlHandler Apache::Registry
    Options +ExecCGI
    PerlSendHeader On
  </Location>

Maintainers ^

Maintainer is the person(s) you should contact with updates, corrections and patches.

Authors ^

Only the major authors are listed above. For contributors see the Changes file.

syntax highlighting: