...where persistent camels roam...

How-to - ModPerl Configuration

This section explains how to edit the main "httpd.conf" file which is used to control the Apache HTTPd server software.

Note:  You will need a text editor.  On Unix there are many choices (e.g., vi, emacs, mc, etc.), and everyone has their favourite that best suits their needs.  On Windows and ReactOS, there are generally two options; a DOS utility called "Edit" or a GUI-based program called "Notepad."  IMPORTANT:  Do NOT use a word processor or else your configuration file may be unreadable by the Apache HTTPd server software!

§ Editing httpd.conf

Locate your "httpd.conf" file (the master Apache HTTPd server configuration file), and open it with your text editor.

  • On BSD/Unix/Linux it is usually stored at either "/etc/httpd.conf" or "/usr/pkg/etc/httpd.conf"
  • On Windows/ReactOS it is usually at "C:/Program Files/Apache Software Foundation/Apache2.2/conf/httpd.conf" (if you upgraded from an older versions, it might also be at either "C:/Apache2/conf/httpd.conf" or "C:/Program Files/Apache Software Group/Apache2.2/conf/httpd.conf")

Attention Windows/ReactOS users -- you will probably need the following information because it is not included in the default configuration:

Various add-ons such as software firewalls, real-time virus scanners, etc., can easily interfere with the advanced functionality that the Apache HTTPd server uses to enhance and optimize web server performance.  If you encounter corrupted or incomplete file downloads, unexplainable error messages, etc., then placing the following directives in your "httpd.conf" file (preferrably somewhere near the beginning/top of the configuration file -- including some preceding comments along the lines of "Ensure reliable operation in Windows/ReactOS" is also highly recommended):

EnableSendfile Off

Starting and stopping Apache HTTPd server varies on each platform.  In BSD/Unix/Linux environments the RC system is typically used although using the "apachectl" command should also work.  On Windows/ReactOS, an icon in the System Tray portraying the famous Apache logo depicting a feather, partly obscured by a white status circle at the bottom-right corner, provides different ways to stop or start Apache HTTPd depending on if you left-click or right-click it with your mouse.

Note:  It's important to be familiar with the process of stopping and starting Apache HTTPd, as well as knowing where to find the log files.

§ Apache modules

Certain modules that are normally included with the Apache HTTPd server installation (and many are compiled in directly), but are disabled by default (because they provide more advanced functionality that aren't needed in most environments) which will need to be enabled.  A few of the modules are also optional, but we will explain why they are useful.

From the beginning of httpd.conf, search for the "LoadModule" directive to locate the list of modules.  Lines that begin with an octothorpe ("#") are disabled since they are treated the same as comments (all comments are preceeded by octothorpes, and may optionally be indented by whitespace characters such as tabs or spaces).

LoadModule include_module modules/
[OPTIONAL]  This module supports SSI (Server Side Include) commands in the form of standard HTML comments embedded directly in HTML files if the "Options +Includes +ExecCGI" directive is also used.  This makes it possible in a very handy way for portions of static HTML files to include dynamic output that is generated your Perl code.  In fact, many web sites that appear to be comprised of static .html files are actually using SSI to call upon Perl scripts (which are also commonly referred to as "CGI scripts") to dynamically generate content.

Although the focus of this guide is on running Perl scripts directly, we will use basic SSI in one section because it can be very useful to make minor dynamic enhancements to static HTML pages on your web sites.  We haven't experienced any server performance/load problems with this module.

LoadModule unique_id_module modules/
[OPTIONAL]  This module generates a unique number for every request, and stores it in the "UNIQUE_ID" environment variable for your Perl scripts to access.  In multi-user scenarios, there are situations where an isolated token (such as a number) is needed to identify something uniquely for a web user, and this module provides a simple solution.  We haven't experienced any server performance/load problems with this module.

After the last "LoadModule" entry, insert a blank line, followed by the directives outlined in the table below (we strongly recommend keeping the comments for future reference).

The "" and "" files listed below should have been copied to your Apache "modules" directory automatically.  In some scenarios you may have to search your hard drive to find these files (this is beyond the scope of this guide as it is specific to each Operating System); for Windows users, the LoadFile directive may also need to be updated if you're using a newer version of Perl.

BSD/Unix/Linux Windows/ReactOS

# ModPerl 2 for Apache 2.2
LoadModule perl_module modules/

# ApReq2 library:  libapreq2
LoadModule apreq_module modules/

# ModPerl 2 for Apache 2.2
LoadFile "C:/perl/bin/perl510.dll"
LoadModule perl_module modules/

# ApReq2 library:  libapreq2
LoadFile "C:/Program Files/Apache Software Foundation/Apache2.2/bin/libapreq2.dll"
LoadModule apreq_module modules/

§ Perl modules

In our guide we will be using a few modules that are available via CPAN (or the PPM if you're using Windows/ReactOS).  Knowing how to add more Perl modules is very important.

The following modules should already be installed because they are normally included with mod_perl2:

  • Apache2::Request
  • Apache2::Upload

The Apache2::Reload module needs to be installed separately, and is particularly useful in non-production environments such as those used by developers.  To install it, use the following command at the shell or command prompt:

  • cpan -i Apache2::Reload

If CPAN requires configuration, aside from selecting mirrors that are geographically close, the rest of the default settings will be fine.

If Windows/ReactOS fails
In Windows/ReactOS the process can be more complicated if using the above cpan command fails (it usually does), in which case a more manual approach from the command prompt should succeed:

  1. Navigate to the /perl/cpan/build/ directory
  2. Navigate to the first Apache-Reload-0.10-XxYyZz sub-directory (where "XxYyZz" is a set of randomly selected letters and/or digits)
  3. Copy the two files manually with one command:  xcopy lib \perl\site\lib /s

The DateTime module is also very useful, and its installation is easy -- in all environments simply type the following command at the shell or command prompt:

  • cpan -i DateTime

If you need additional Perl modules, you can add them at any time and ModPerl will automatically have access to them.

Previous | Index | Next

Home | Contact us
Copyright © Inter-Corporate Computer & Network Services, Inc.  All rights reserved.
All trademarks are the property of their respective owners.