How to Install and configure mod_perl for Apache in Linux


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 perl.apache.org as shown below.

[root@server~]# wget http://perl.apache.org/dist/mod_perl-2.0.7.tar.gz

[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 “libgdbm.so was not found. You could just symlink it to /usr/lib/libgdbm.so.2.0.0″ , 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

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 modules directory.

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

/usr/lib/httpd/modules/

[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 libphp5.so

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

|                                                                                                                          |

|   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

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

LoadModule perl_module modules/mod_perl.so

Restart the Apache.

[root@server~]# service httpd restart

5. Verify mod_perl is installed

If everything goes smoothly, you’ll see mod_perl.so 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 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.

[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

About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Apache. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s