i have a 1and1 hosting account and would like to install some Perl CPAN modules that are not part of the standard host package. Is it possible to install modules without ROOT access? If so, how do i do that? Thanks for the pointers in advance.
Asked
Active
Viewed 1.9k times
12
-
Ask your hosting provider support also. Some are willing to install CPAN modules on request. If not, there's the answers below. – evil otto Aug 16 '11 at 01:21
-
From the [Stack Overflow Perl FAQ](http://stackoverflow.com/questions/tagged/perl?sort=faq): [How can I install a CPAN module into a local directory?](http://stackoverflow.com/questions/540640/how-can-i-install-a-cpan-module-into-a-local-directory) – daxim Aug 24 '11 at 10:09
5 Answers
16
cpanminus is quickly becoming the choice interface for CPAN. It supports installing packages in to the user's home directory.
Its usage is frightening simple. To install the cpanminus package locally:
curl -L http://cpanmin.us | perl - App::cpanminus
To install an arbitrary package:
curl -L http://cpanmin.us | perl - Lingua::Romana::Perligata
Remember to add the user's local library to the PERL5LIB environment variable.
export PERL5LIB=$HOME/perl5/lib/perl5:$PERL5LIB

vim keytar
- 391
- 1
- 5
-
Re "It supports installing packages in to the user's home directory.", Could you please should show how to do that? It's not mentioned in the documentation to which you linked. – ikegami Aug 13 '14 at 13:39
-
I would just add a caution about PERL5LIB. If you have multiple perl installations on a system using PERL5LIB widely (i.e. setting it in shell startup files) can break some scripts as you could end up pointing one perl to another perl's potentially incompatible modules. This has caused huge issues where I work. – trent Jan 26 '17 at 14:10
8
I would suggest you use perlbrew
and install a whole build of Perl in your account, not just modules. Less headaches that way, especially when the provider decides to update the system Perl.

ikegami
- 367,544
- 15
- 269
- 518
-
But then you have to change the `#!/usr/bin/perl` line at the top of each script. – Keith Thompson Aug 16 '11 at 01:23
-
8In most systems, you can do `#! /usr/bin/env perl` which will execute the version of Perl in your `$PATH`. I've switched over to that about five or so years ago because I was tired of the constant `/bin/perl` vs. `/usr/bin/perl` vs. `/usr/share/bin/perl` vs. `/usr/local/bin/perl`. If you're going to change the top line of all your scripts anyway, might as well do it in such a way you'll never have to do it again. – David W. Aug 16 '11 at 01:43
-
@Keith Thompson, Yes (unless they're installed using Makefile.PL/Build.PL), but so what? You can fix all the scripts in an entire directory tree with one command if you so desire. A minute's effort you can do when Perl is being installed. – ikegami Aug 16 '11 at 01:53
5
This is an excellent article about installing perl modules as a regular (non-root) user:

ennuikiller
- 46,381
- 14
- 112
- 137
-
1This predates things like `perlbrew`, `cpanm`, and `local::lib` so while it is a nice walk-through it is definitely not what I’d recommend or try to use. – Ashley Aug 16 '11 at 04:21
4
For installing modules to a local directory, you can use local::lib
.

Alan Haggai Alavi
- 72,802
- 19
- 102
- 127