mod_perl logo perl icon
previous page: mod_perl 1.0 Win32 Installation Instructionspage up: Win32 Platformsnext page: Discussion of multithreading on Win32 mod_perl 1.xx

mod_perl 1.0 Win32 Configuration Instructions






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
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


Table of Contents

Description

This document discusses how to configure mod_perl 1.0 under Win32.



TOP

Configuration

Add this line to C:\Apache\conf\httpd.conf:

 LoadModule perl_module modules/mod_perl.so

Be sure that the path to your Perl binary (eg, C:\Perl\bin) is in your PATH environment variable. This can be done either through editing C:\AutoExec.bat, if present, or through the Environment Variables option of the Advanced tab in the System area of the Control Panel. Especially when running Apache as a service, you may also want to add

 LoadFile "C:/Path/to/Perl/bin/perl56.dll"

in httpd.conf, before loading mod_perl.so, to load your perl dll.

If you have a ClearModuleList directive enabled in httpd.conf, you may also need to add

 AddModule mod_perl.c

See the descriptions of the ClearModuleList and AddModule directives in the Apache documents for more details, especially concerning the relative order of these and the LoadModule directive.



TOP

Registry scripts

Using Apache::Registry to speed up cgi scripts may be done as follows. Create a directory, for example, C:\Apache\mod_perl, which will hold your scripts, such as

  ##  printenv -- demo CGI program which just prints its environment
  ##
  use strict;
  print "Content-type: text/html\n\n";
  print "<HTML><BODY><H3>Environment variables</H3><UL>";
  foreach (sort keys %ENV) {
    my $val = $ENV{$_};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "<LI>$_ = \"${val}\"</LI>\n";
  }
  #sleep(10);
  print "</UL></BODY></HTML>";

Note that Apache takes care of using the proper line endings when sending the Content-type header. Next, insert in C:\Apache\conf\httpd.conf the following directives:

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

whereby the script would be called as

   http://localhost/mod_perl/name_of_script


TOP

Hello World

As you will discover, there is much to mod_perl beyond simple speed-up of cgi scripts. Here is a simple Hello, World example that illustrates the use of mod_perl as a content handler. Create a file Hello.pm as follows:

  package Apache::Hello;
  use strict;
  use Apache::Constants qw(OK);
  
  sub handler {
     my $r = shift;
     $r->send_http_header;
     $r->print("<html><body>Hello World!</body></html>\n");
     return OK;
   }
  
  1;

and save it in, for example, the C:\Perl\site\lib\Apache\ directory. Next put the following directives in C:\Apache\conf\httpd.conf:

  PerlModule Apache::Hello
  <Location /hello>
     SetHandler perl-script
     PerlHandler Apache::Hello
  </Location>

With this, calls to

   http://localhost/hello

will use Apache::Hello to deliver the content.



TOP

Apache modules

The theorxy5 repository containing the mod_perl ppm package also contains a number of other Apache modules, such as Apache::ASP, HTML::Embperl, and HTML::Mason. However, there may be ones you find that are not available through a repository; in such cases, you might try sending a message to the maintainer of the repository asking if a particular package could be included.

Alternatively, you can use the CPAN.pm module to fetch, build, and install the module - see perldoc CPAN for details. You will need the nmake utility for this, download it from http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe (it's a self extracting archive, so run it and then copy the files to somewhere in your PATH environment variable).



TOP

See Also

The directions for installing mod_perl 1.0 on Win32, the mod_perl documentation, and the FAQs for mod_perl on Win32. Help is also available through the archives of and subscribing to the mod_perl mailing list.



TOP

Maintainers

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



TOP

Authors

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






TOP
previous page: mod_perl 1.0 Win32 Installation Instructionspage up: Win32 Platformsnext page: Discussion of multithreading on Win32 mod_perl 1.xx