If you are already a Perl developer on Windows, it is likely that you have ActivePerl (see http://www.activestate.com/) installed. In that case, you can get a mod_perl distribution that takes advantage of your existing Perl installation.

First of all, you will need to get the latest Apache distribution. Go to http://www.apache.org/dist/httpd/binaries/win32/ and get the latest version of apache_1.3.xx-win32-no_src.msi, which is a graphical installer. Read the notes on that page about the MSI Binary distribution carefully if you are using Windows NT 4.0 or Windows 9x, as there may be some prerequisites.

There is a lot of documentation at http://httpd.apache.org/ about installing Apache on Windows, so we won't repeat it here. But for the purposes of this example, let's suppose that your Apache directory is C:\Apache, which means you chose C:\ as the installation directory during the installation of Apache, and it created a subdirectory named Apache there.

Once Apache is installed, we can install mod_perl. mod_perl is distributed as a PPM file, which is the format used by the ActivePerl ppm command-line utility. mod_perl isn't available from ActiveState, but it has been made available from a separate archive, maintained by Randy Kobes.[12] To install mod_perl, do the following from a DOS prompt:

[12]See the Preface for more information about PPM installation.

C:\> ppm
PPM> install mod_perl
PPM> quit

When install mod_perl completes, a post-installation script will run, asking you where to install mod_perl.so, the mod_perl dynamic link library (DLL) that's used by Apache. Look over the suggested path and correct it if necessary, or press Enter if it's correct; it should be the C:\Apache\modules directory if you used C:\Apache as an installation directory.

Please note that the version of mod_perl provided in that archive is always the latest version of mod_perl compiled against the latest version of Apache, so you will need to make sure you have the latest Apache (of the 1.3.x series) installed before proceeding. Furthermore, you will need an ActivePerl installation from the 6xx series, based on Perl 5.6.x, or mod_perl won't work.

The next step is to enable mod_perl in your httpd.conf file. If you installed Apache in C:\Apache, this will be C:\Apache\conf\httpd.conf.

Add this line together with any other LoadModule directives:

LoadModule perl_module modules/mod_perl.so

Furthermore, if you have a ClearModuleList directive in the same file, add the following line with the other AddModule directives:

AddModule mod_perl.c

For more information, see the Apache documentation for these two directives, and see Chapter 3 for more information on using mod_perl as a dynamic shared object (DSO).

With this installation, you can start Apache as described in its documentation, and try out the examples in this book. However, the mod_perl test scripts cited above aren't provided, and you will have to configure mod_perl yourself. See Chapter 4 for more information about configuring mod_perl. For example:

Alias /perl/ C:/Apache/perl/

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

This will allow you to run Apache::Registry scripts placed in the directory C:\Apache\perl. As you may have noticed, we use forward slashes instead of the backslashes that are used on Windows (i.e., C:/Apache/perl/ instead of C:\Apache\perl\), to be compatible with Unix notation.