mod_perl logo perl icon
no previous pagepage up: What is mod_perl?no next page

Apache::Registry Example






Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

By Lincoln Stein, Doug MacEachern
Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

By Dave Rolsky, Ken Williams
mod_perl2 User's Guide

mod_perl2 User's Guide

By Stas Bekman, Jim Brandt
Practical mod_perl

Practical mod_perl

By Stas Bekman, Eric Cholet
The mod_perl Developer's Cookbook

The mod_perl Developer's Cookbook

By Geoffrey Young, Paul Lindner, Randy Kobes
mod_perl Pocket Reference

mod_perl Pocket Reference

By Andrew Ford


Table of Contents

Running CGI scripts with mod_perl

Existing CGI scripts will run much faster under mod_perl. And converting existing CGI scripts to run under mod_perl is easy.

For example, here's an existing CGI script called hello.cgi.

  file:hello.cgi
  --------------
  #!/usr/local/bin/perl -w
  use strict;
  use CGI;
  my $q = CGI->new;
  print $q->header,
        $q->start_html,
        $q->h1('Hello World!'),
        $q->end_html;

This script can now be run as-is under Apache::Registry by using the following configuration in httpd.conf:

  <Files hello.cgi>
      SetHandler perl-script
      PerlHandler Apache::Registry
      Options ExecCGI
  </Files>

That's basically it. Your scripts do need to be well coded, but there's even the Apache::PerlRun module to help with those "less clean" programs.

So how much faster do scripts run under Apache::Registry? Obviously, it depends on the script, but the hello.cgi script above ran at 7.3 requests per second as a CGI script and 243.0 requests per second with Apache::Registry.

Tested with Apache Benchmark (ab -n 1000) on Linux PIII-550Mhz, Apache version 1.3.20

For more information on running CGI scripts under mod_perl please see the CGI to mod_perl Porting section of The Guide.

« back




TOP
no previous pagepage up: What is mod_perl?no next page