Stop Referrer Log Spam Published: Nov 13, 2005
  • Rating


mod_perl Install Guide with step by step instructions making Perl run faster and better with Apache.

How-To Install Mod_perl

Perl/CGI is a very powerful programming language but when used for web applications it can really tax your server’s resources, specifically the CPU.  With CGIProxy, a web based anonymizer similar to; I had noticed my server’s load (A 3.4ghz Pentium 4 with HT and 2GB of RAM) consistently hitting 40 during peak hours.

Fortunately this particular script was designed to work with mod_perl.  Mod_perl is an apache module that loads a separate perl interpreter inside apache at the minute cost of memory and with a drastic reduction of CPU usage.

After configuring mod_perl with apache for this particular script, the server load at peak hovers is healthy at 2, even with twice the visitors!

Configuring mod_perl to work with apache was difficult for me at first, so hopefully this article assist anyone interested in putting this wonderful module to use.  This tutorial is geared for a cPanel server running Apache 1.x and mod_perl 1.x however the httpd.conf instructions should work with any Apache 1.x server with mod_perl installed.

Ensure you are logged in as root in shell and follow these steps:

Compile mod_perl with apache in cPanel:
1. type: /scripts/easyapache
2. check for “Perl Module” and make sure it’s enabled
3. Save and Exit

To verify that Apache was configured with mod_perl type:
            /usr/local/apache/bin/httpd –l
It should list: mod_perl.c

Now that Apache has mod_perl loaded as a module, we’ll need to edit our httpd.conf (Apache Config. File) but first it’s a good idea to make a back up:
1. Go into the Apache conf directory: cd /usr/local/apache/conf/
2. Backup: cp httpd.conf httpd.conf.bak
3. Edit: pico httpd.conf

Go to where it your modules are being loaded, it should be under the “Dynamic Shared Object (DSO) Support” section.  Add the following line under the last loaded module:
AddModule mod_perl.c

Now we’ll need to the following information to make any CGI script inside the cgi-bin to be processed with mod_perl & apache instead of Perl.

PerlModule Apache::Registry
<Location /cgi-bin>
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
PerlSendHeader Off
allow from all

The above lines were added inside the VirtualHost entry of my account.

Go ahead and save the file, exit, and restart Apache.

To verify that the changes check your running processed by typing in the command: top cd1

If the CGI script is still running from Perl then the process command will begin with something similar to: /usr/local/bin/perl.  However if you see a copy of Apache loading when the CGI process is executed (/usr/local/apache/bin/httpd –DSSL) then congrats, you’ve configured mod_perl successfully!

About the Author:
Chad Bean is the co-founder of


  • Rating


Related Articles

Comments (0)

No one has commented on this page yet.

Add Your Thoughts is a hosting directory, not a web host.

Copyright © 1998-2024