Home » , » UNIX / Linux: How to Install and Configure mod_perl for Apache 2

UNIX / Linux: How to Install and Configure mod_perl for Apache 2

Written By 1 on Wednesday, March 2, 2011 | 10:54 PM


If you are running any web based open source application that is written in perl, you should be using mod_perl with Apache instead of running it as CGI. mod_perl is way faster than running a web application using CGI.
This article explains how to install mod_perl on Apache 2.
First, install Apache 2, if you don’t have it already.

1. Download mod_perl

Download mod_perl from perl.apache.org as shown below.
# cd ~

# wget http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz

# tar xvfz mod_perl-2.0-current.tar.gz

# cd mod_perl-2.0.4/

2. Configure mod_perl with Apache2

Specify the location of your Apache 2 installation to the mod_perl as shown below.
# perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs

Reading Makefile.PL args from @ARGV
MP_APXS = /usr/local/apache2/bin/apxs
no conflicting prior mod_perl version found - good.
Configuring Apache/2.2.15 mod_perl/2.0.4 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 “libgdbm.so was not found. You could just symlink it to /usr/lib/libgdbm.so.2.0.0″ message, install the gdbm-devel package as shown below.
# rpm -ivh gdbm-devel-1.8.0-26.2.1.i386.rpm

# rpm -qa | grep gdbm
gdbm-devel-1.8.0-26.2.1
gdbm-1.8.0-26.2.1
At this stage, the mod_perl is still not installed, which you can verify by checking the contents of the Apache 2 modules directory.
# /usr/local/apache2/bin/apxs -q LIBEXECDIR
/usr/local/apache2/modules

# ls -l /usr/local/apache2/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 libphp5.so

3. Make and install the mod_perl

First, do a make test, to make sure everything looks good.
# 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 Apache2.
# 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: |
| |
| http://perl.apache.org/docs/2.0/user/intro/start_fast.html |
| |
| |
| Found a bug? File a bug report: |
| |
| http://perl.apache.org/bugs/ |
| |
+--------------------------------------------------------------+

4. Modify httpd.conf and Restart Apache

Modify the httpd.conf to load the mod_perl.so as shown below
# grep perl /usr/local/apache2/conf/httpd.conf
LoadModule perl_module modules/mod_perl.so
Restart the Apache.
# /usr/local/apache2/bin/apachectl restart

5. Verify mod_perl is installed

If everything goes smoothly, you’ll see mod_perl.so under the apache modules directory.
# ls -l /usr/local/apache2/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 libphp5.so
-rwxr-xr-x 1 root root 1264743 Jun 21 10:01 mod_perl.so
Apache error_log will also show that mod_perl is installed as shown below.
# tail /usr/local/apache2/logs/error_log
[notice] Apache/2.2.15 (Unix) PHP/5.3.2 mod_perl/2.0.4 Perl/v5.8.8 configured

0 Comment:

Post a Comment