SHARE
Facebook X Pinterest WhatsApp

Installation of mod_perl-enabled Apache Without Superuser Privileges Page 3

Written By
thumbnail Stas Bekman
Stas Bekman
Jul 20, 2010
ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More



Another way is to write code to modify @INC explicitly:

  BEGIN {
    unshift @INC,
      qw(/home/stas/lib/perl5/5.00503
         /home/stas/lib/perl5/5.00503/i386-linux
         /home/stas/lib/perl5/site_perl/5.005
         /home/stas/lib/perl5/site_perl/5.005/i386-linux);
        }

Note that with the lib module we don’t have to list the
corresponding architecture specific directories, since it adds them
automatically if they exist (to be exact, when //auto
exists).

Also, notice that both approaches prepend the directories to be
searched to @INC. This allows you to install a more recent module
into your local repository and Perl will use it instead of the older one
installed in the main system repository.

Both approaches modify the value of @INC at compilation time.
The lib module uses the BEGIN block as well, but
internally.

Now, let’s assume the following scenario. I have installed the
LWP package in my local repository. Now I want to install another
module (e.g. mod_perl) and it has LWP listed in its prerequisites
list. I know that I have LWP installed, but when I run perl
Makefile.PL
for the module I’m about to install I’m told that I don’t
have LWP installed.

There is no way for Perl to know that we have some locally installed
modules. All it does is search the directories listed in @INC, and
since the latter contains only the default four directories (plus the
. directory), it cannot find the locally installed
LWP package. We cannot solve this problem by adding code to modify
@INC, but changing the PERL5LIB environment variable
will do the trick. If you are using t?csh for interactive work, do
this:

  setenv PERL5LIB /home/stas/lib/perl5/5.00503:
  /home/stas/lib/perl5/site_perl/5.005

It should be a single line with directories separated by colons
(:) and no spaces. If you are a (ba)?sh user, do
this:

  export PERL5LIB=/home/stas/lib/perl5/5.00503:
  /home/stas/lib/perl5/site_perl/5.005

Again, make it a single line. If you use bash you can use multi-line
commands by terminating split lines with a backslash (), like
this:

  export PERL5LIB=/home/stas/lib/perl5/5.00503:  /home/stas/lib/perl5/site_perl/5.005

As with use lib, perl automatically prepends the architecture
specific directories to @INC if those exist.

When you have done this, verify the value of the newly configured
@INC by executing perl -V as before. You should see
the modified value of @INC:

  % perl -V
  
  Characteristics of this binary (from libperl): 
  Built under linux
  Compiled at Apr  6 1999 23:34:07
  %ENV:
    PERL5LIB="/home/stas/lib/perl5/5.00503:
    /home/stas/lib/perl5/site_perl/5.005"
  @INC:
    /home/stas/lib/perl5/5.00503/i386-linux
    /home/stas/lib/perl5/5.00503
    /home/stas/lib/perl5/site_perl/5.005/i386-linux
    /home/stas/lib/perl5/site_perl/5.005
    /usr/lib/perl5/5.00503/i386-linux
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i386-linux
    /usr/lib/perl5/site_perl/5.005
    .

When everything works as you want it to, add these commands to your
.tcshrc or .bashrc file. The next time you start a
shell, the environment will be ready for you to work with the new Perl.

thumbnail Stas Bekman

Stas Bekman is a ServerWatch contributor.

Recommended for you...

What Is a Container? Understanding Containerization
What Is a Print Server? | How It Works and What It Does
Nisar Ahmad
Dec 8, 2023
What Is a Network Policy Server (NPS)? | Essential Guide
Virtual Servers vs. Physical Servers: Comparison and Use Cases
Ray Fernandez
Nov 14, 2023
ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.