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:
- Create a directory for the perl modules in your HOME
$ mkdir ~/perl5lib- Create ~/.cpan and ~/.cpan/CPAN directories:
mkdir ~/.cpan
mkdir ~/.cpan/CPAN
- Create a Config.pm for the CPAN module with
$CPAN::Configempty
$ echo “\$CPAN::Config = {}”> ~/.cpan/CPAN/MyConfig.pm- 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:
- Exit the cpan interactive shell
- Pick a directory where you want to keep your local copy of perl modules. I chose: ~/perl as the prefix.
- Create the directory there and make sure you have permissions to write.
- Start the cpan interactive shell again using $ perl -MCPAN -e shell
- You need to re-configure the conf to point at your new directory.
- o conf makepl_arg “LIB=~/perl/lib \
INSTALLMAN1DIR=~/perl/man/man1 \
INSTALLMAN3DIR=~/perl/man/man3″ - o conf commit ( this will make the changes permanent )
- exit the cpan interactive shell again and modify your env vars to point at the new locations
- export PERL5LIB=${PERL5LIB}:~/perl/lib (If you want this to be permanent then modify your ~/.bashrc)
- restart the cpan interactive shell and you’re set to start installing
Tags: 1&1, 1and1, perl, perl modules, shared hosting
October 29th, 2008 at 4:39 am
Interesting to know.
April 22nd, 2009 at 10:12 am
Here’s the conf. I used:
o conf makepl_arg “PREFIX=~/perl5lib INSTALLDIRS=perl LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man/man1 INSTALLMAN3DIR=~/perl5lib/man/man3″