Installing Perl Modules on 1and1

I was trying to figure out how to install perl modules on my hosting provider 1and1.com. I was doing an old school install where I was unpacking and making the modules myself. Yep… as usual there was a better way. Yes, I’m a bonehead but since I need a scapegoat I’m blaming it on the Yahoo dev environment. It’s made me soft and I needed to figure out the right way to do this.

That said, cpan.pm comes with most standard perl installs and totally makes installing modules easier. It handles dependencies, downloads, unpacking, etc. All I really had to do was configure the env. This seemed to be the one snag that wasn’t well documented. I was getting something like the following error when running $ perl -MCPAN -e shell:

Your configuration suggests “/root/.cpan” as your CPAN.pm working directory. I could not create this directory due to this error: mkdir /root/.cpan: Permission denied at /usr/lib/perl5/5.6.1/CPAN.pm line 499
Please make sure the directory exists and is writable.

The solution was found here:
  http://www.dcc.fc.up.pt/~pbrandao/aulas/0203/AR/modules_inst_cpan.html

The site describes the following steps which I modified to work for me:

  1. Create a directory for the perl modules in your HOME
    $ mkdir ~/perl5lib
  2. Create ~/.cpan and ~/.cpan/CPAN directories:
    mkdir ~/.cpan
    mkdir ~/.cpan/CPAN

  3. Create a Config.pm for the CPAN module with $CPAN::Config empty
    $ echo “$CPAN::Config = {}”> ~/.cpan/CPAN/MyConfig.pm
  4. Execute again:
    $ perl -MCPAN -e shell
    This time (if all goes well) it will prompt you for the empty fields in $CPAN::Config.

Here’s where I modified things:

  1. Exit the cpan interactive shell
  2. Pick a directory where you want to keep your local copy of perl modules. I chose: ~/perl as the prefix.
  3. Create the directory there and make sure you have permissions to write.
  4. Start the cpan interactive shell again using $ perl -MCPAN -e shell
  5. You need to re-configure the conf to point at your new directory.
  6. o conf makepl_arg “LIB=~/perl/lib
    INSTALLMAN1DIR=~/perl/man/man1
    INSTALLMAN3DIR=~/perl/man/man3″
  7. o conf commit ( this will make the changes permanent )
  8. exit the cpan interactive shell again and modify your env vars to point at the new locations
  9. export PERL5LIB=${PERL5LIB}:~/perl/lib (If you want this to be permanent then modify your ~/.bashrc)
  10. restart the cpan interactive shell and you’re set to start installing