Installing mod_perl

If you already have Apache installed on your machine, you will have to rebuild it with mod_perl. You can get the source for both Apache and mod_perl from http://www.apache.org/. (You can also get mod_perl from CPAN.) If there isn’t already an Apache httpd in the Apache source tree, you must build one. Then build mod_perl as directed in the INSTALL file for the mod_perl distribution.

As we’ve mentioned, mod_perl allows you to hook in Perl modules as handlers for various stages of a request. By default, however, the only callback hook that is enabled is PerlHandler, which is the one that processes content (i.e., a CGI document). If you want to use other hooks—for example, to extend Apache’s logging facilities via the PerlLogHandler directive; you need to specify it at build time as directed in the INSTALL file. For example:

% perl Makefile.PL PERL_LOG=1

The mod_perl Makefile replaces the httpd in the Apache source tree with a Perl-enabled one. When you install mod_perl, it installs not only the new httpd in your system area, but also several Perl modules, including Apache::Registry.

At the time of this writing, both Apache and mod_perl are being ported to Win32. However, mod_perl runs only with the standard Perl Win32 port (not with ActiveState’s). The INSTALL.win32 file contains the instructions for installing mod_perl under Win32.

Get Webmaster in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.