where username is your shell name, perlmods is what you chose above as the local CPAN install directory, and 5.x and 5.x.x refer to the currently installed Perl version determined by perl -v.

What if I see an error?

If the above cpan command generates an error like the following:

Your configuration suggests that CPAN.pm should use a working
directory of
/root/.cpan
Unfortunately we could not create the lock file
/root/.cpan/.lock
due to permission problems.
Please make sure that the configuration variable
$CPAN::Config->{cpan_home}
points to a directory where you can write a .lock file. You can set
this variable in either
/etc/perl/CPAN/Config.pm
or
/home/username/.cpan/CPAN/MyConfig.pm
Could not open >/root/.cpan/.lock: Permission denied

then you must manually create a ~/.cpan/CPAN/MyConfig.pm file before proceeding to the next step (this is because root already configured cpan in your host.)

Installing Module::Build and many other modules

If you're installing Module::Build or others which use Module::Build in their installation, it might help to add the above PERL5LIB lines to your .profile (or .bash_profile), otherwise anything you build won't know how to read the Module::Build Build script.

Other modules

Please note that some modules will not install correctly from CPAN as non-root and to a non-standard path. They must be built and installed manually (that is, using the build scripts provided with the modules). Two specifically are:

DateTime

DateTime (as of 0.68) requires the install step to be executed like so using the "--install_base" option:

[server]$ ./Build install --install_base ~/perlmods

IO:Compress

IO::Compress (as of 2.034) requires tweaking the Makefile because one of the target paths ignores the PREFIX environment variable.

Generate the Makefile using:

[server]$ perl Makefile.PL PREFIX=~/perlmods

Open up the Makefile and look for this line:

INSTALLARCHLIB = /usr/lib/perl/5.10

Change it to say:

INSTALLARCHLIB = $(SITEPREFIX)/lib/perl/5.10

Proceed with your make/make test/make install.

Configuring CPAN

If you need to manually configure settings, you can access your configuration in the file:

~/.cpan/CPAN/MyConfig.pm

If specifying PREFIX as above, then use the full path to your perlmods directory:

PREFIX=/home/username/perlmods

Use perldoc to get a listing of CPAN settings that you can edit:

[server]$ perldoc CPAN

Using CPAN Minus and local::lib

Tatsuhiko Miyagawa's CPAN Minus (githubcpan) makes it even easier to add support for your own Perl modules. Use

[server]$ cpanm -L ~/perlmod module...

to install modules into ~/perlmod. In your script, enter the following:

use local::lib '~/perlmod';

to use these modules.

Killed

There is a procwatch daemon running that may kill your perl installs. Visit the procwatch article for more information.

Did this article answer your questions?

Sending feedback...

This form is only for article feedback. If you require assistance, please contact support.
How can we improve this page?

Thank you for your feedback!

We'll use it to improve the Knowledge Base.

If you still require assistance, and you're an existing DreamHost customer, please contact support.

If you're not a customer yet, please contact our sales team for further assistance.