Georgio has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

You see I need to install a Perl module (created by me) on my server that
will be used by a particular script. The thing is that I want this module to
be available to all user accounts on this server, but since there are a way
too many accounts I don't want to copy it into each account. I was wondering
if there is a way to place that module in some root folder and make
available to all user accounts?

Please advise me how to do this.

Thanks.

  • Comment on Install a Perl module for all user accounts

Replies are listed 'Best First'.
Re: Install a Perl module for all user accounts
by ferreira (Chaplain) on Jan 02, 2007 at 18:12 UTC

    When a Perl module is installed (via the Perl mantra "perl Makefile.PL; make; make test; make install") without additional parameters for customization, it ends up being installed with everything else available to any user of the Perl interpreter itself. (But site modules are kept separate from core/builtin modules yet.)

    To install modules, it is usual to employ the same user that did the installation of the interpreter. That is why it is common to have this variation of the commands:

    $ perl Makefile.PL $ make $ make test $ sudo make install # after everything looks ok, # get the appropriate privileges and install

    This or any more well-behaved routine with special users and tailored permissions to improve security will work smoothly in general.

    Other alternative is to set the environment variable PERL5LIB with the additional paths where your modules are installed and to make it visible to every user you care for. But this will be harder to maintain, but yet feasible.

    Read more in perlrun, section ENVIRONMENT.

Re: Install a Perl module for all user accounts
by jettero (Monsignor) on Jan 02, 2007 at 17:46 UTC

    It's probably the wrong way to do it, but technically you can copy files by hand into /usr/lib/perlx/site_perl/5.x.x/. That location could be wrong on your machine, try perl -e 'print "@INC\n"' for a list of possible default locations.

    Arguably, the correct way to do it is to look at Module::Build or ExtUtils::MakeMaker (oldschool but still my favorite of the two) and then mostly ignore those documents by using h2xs — which helps you use the current best practices (by default).

    -Paul

Re: Install a Perl module for all user accounts
by Anonymous Monk on Jan 02, 2007 at 17:47 UTC

    The other users can use any module to which they have access. You just need to set the permissions of the folder into which the module was installed such that the other users can read the files there.

    By the way, aren't modules installed in "some root folder" by default?