To run web based open source application that is written in perl, it is recommended to use mod_perl with Apache instead of running it as CGI. mod_perl is way faster than running a web application using CGI.

In this article we will learn how to install mod_perl for Apache.

1. Download mod_perl

Download latest mod_perl package from as shown below.

[root@server~]# wget

[root@server~]# tar zxvf mod_perl-2.0.7-current.tar.gz

[root@server~]# cd mod_perl-2.0.7/

2. Configure mod_perl with Apache

Specify the location of your Apache 2 installation to the mod_perl as shown below.

[root@server~]# perl Makefile.PL MP_APXS=/usr/sbin/apxs

Reading Makefile.PL args from @ARGV

MP_APXS = /usr/sbin/apxs

no conflicting prior mod_perl version found – good.

Configuring Apache/2.2.15 mod_perl/2.0.7 Perl/v5.8.8

Checking if your kit is complete…

Looks good

Writing Makefile for ModPerl

Writing Makefile for ModPerl::XS

Writing Makefile for mod_perl2

Note: If you encounter the “ was not found. You could just symlink it to /usr/lib/″ , install the gdbm-devel package as shown below.

[root@server~]# rpm -ivh gdbm-devel-1.8.0-26.2.1.i386.rpm

[root@server~]# rpm -qa | grep gdbm



At this stage, the mod_perl is still not installed, which you can verify by checking the contents of the Apache modules directory.

[root@server~]# /usr/sbin/apxs -q LIBEXECDIR


[root@server~]#  ls -l /usr/lib/httpd/modules/

total 16512

-rw-r–r– 1 root root     9083 May 18 09:59 httpd.exp

-rwxr-xr-x 1 root root 16871365 May 19 03:44

3. Make and install the mod_perl

First, do a make test, to make sure everything looks good.

[root@server~]# make test

t/special_blocks.t … ok

All tests successful.

Files=20, Tests=84, 14 wallclock secs ( 0.17 usr  0.06 sys +  9.10 cusr  1.46 csys = 10.79 CPU)

Result: PASS

Finally, do a make install to install the mod_perl on Apache.

[root@server~]# make install

Installing /usr/share/man/man3/Apache::TestReport.3pm

Installing /usr/share/man/man3/ModPerl::Global.3pm

Installing /usr/bin/mp2bug

Appending installation info to /usr/lib/perl5/5.8.8/i386-linux-thread-multi/perllocal.pod


|                                                                                                                          |

| For details on getting started with mod_perl 2, see:                               |

|                                                                                                                          |

|             |

|                                                                                                                          |

| Found a bug?  File a bug report:                                                                 |

|                                                                   |

|                                                                                                                          |


4. Modify httpd.conf and Restart Apache

Modify the httpd.conf to load the as shown below

[root@server~]# grep perl /etc/httpd/conf/httpd.conf

LoadModule perl_module modules/

Restart the Apache.

[root@server~]# service httpd restart

5. Verify mod_perl is installed

If everything goes smoothly, you’ll see under the apache modules directory.

[root@server~]# ls -l /usr/lib/httpd/modules/

total 17752

-rw-r–r– 1 root root     9083 May 18 09:59 httpd.exp

-rwxr-xr-x 1 root root 16871365 May 19 03:44

-rwxr-xr-x 1 root root  1264743 Jun 21 10:01

Apache error_log will also show that mod_perl is installed as shown below.

[root@server~]# tail /usr/local/apache2/logs/error_log

[notice] Apache/2.2.15 (Unix) PHP/5.3.2 mod_perl/2.0.7 Perl/v5.8.8 configured

Posted in: Linux.
Last Modified: January 12, 2017

Leave a reply