Pivotal Knowledge Base

Follow

How can I build and use an updated Perl/mod_perl with my ERS Apache installation? (2007812_draft)

How can I build and use an updated Perl/mod_perl with my ERS Apache installation? (2007812_draft)

Purpose

While mod_fcgid can be used for a Perl CGI application, mod_perl offers the ability to access and control various phases of the Apache server and request lifecycles. This article discusses how to build and use mod_perl associated with the system Perl installation.

Resolution

To begin with, the mod_perl source should be downloaded and the archive file expanded. mod_perl is available at http://perl.apache.org/download. In the top-level mod_perl directory, mod_perl can then be built as shown below. The vFabric Web Server httpd apxs script should be modified, if necessary, to point to the system perl with its shebang line (i.e., #!/usr/bin/perl -w).

(Note: $ERS_HOME should be set to, or replaced with, the path of your ERS installation's top-level directory)

$ perl Makefile.PL MP_APXS=$ERS_HOME/apache2.2/bin/apxs
$ make
$ . $ERS_HOME/apache2.2/bin/envvars
$ make test
$ sudo make install

This should result in mod_perl.so being created in the $ERS_HOME/apache2.2/modules directory.  At this point, you could try simply changing the ERS instance's conf/httpsd.conf to load this new mod_perl.so rather than the original per/mod_perl.so. Doing this will likely result in ERS Apache failing to start due to a Segmentation fault. This is due to settings in the ERS Apache instance's conf/startup.pl script.  The sections that will need to change are the shebang line (line 1) to reference the system Perl rather than the ERS Perl, and the Perl @INC array.  This script is referenced in the ERS Apache instance's conf/httpsd.conf with the directive:

PerlRequire "$ERS_HOME/servers/<Instance Name>/conf/startup.pl"

To resolve this issue:

1) Copy the original startup.pl to some new file (i.e., sudo cp conf/startup.pl conf/startup-mod_perl-2.0.5.pl).

2) Edit this new startup file to set the @INC array to something similar to (this depends on your Perl installation. I am using Perl 5.10.1 on Ubuntu 10.10):

    unshift @INC,
        "/usr/local/lib/perl/5.10.1",
        "/usr/lib/perl/5.10.1",
        "/usr/share/perl/5.10.1";

3) Edit the conf/httpsd.conf to reference this new startup file:

PerlRequire "$ERS_HOME/servers/<Instance Name>/conf/startup-mod_perl-2.0.5.pl"

After making these changes, the ERS Apache instance should start with the new mod_perl.  This can be verified with the startup message in the ERS Apache instance's error log (assuming a different Perl version is being used):

ERS/4.0.3 Apache/2.2.17 startup message with bundled Perl/mod_perl:

[Fri Oct 07 08:39:07 2011] [notice] Apache/2.2.17 (Unix) DAV/2 mod_perl/2.0.4 Perl/v5.8.8 configured -- resuming normal operations


ERS/4.0.3 Apache/2.2.17 startup message with system Perl and new mod_perl:

[Fri Oct 07 08:59:01 2011] [notice] Apache/2.2.17 (Unix) DAV/2 mod_perl/2.0.5 Perl/v5.10.1 configured -- resuming normal operations

Additional Information

http://perl.apache.org/
©VMware 2013

Comments

Powered by Zendesk