How do I install the Perl 5 CGI libraries (CGI, LWP and more)? How can CPAN.pm help?
Contributors:
- Stas sbekman@hotmail.com
- Stas sbekman@hotmail.com
- Stas sbekman@hotmail.com
If you do not have root access, you will need to install these modules in an alternate location. If you were installing these tools as root, you would do it like this:
perl Makefile.PL
make
make test
make install
To do this in an alternate location, first create
the directory you will use instead. If that directory
is called /path_to_your_home/lib/perl5, then you
install the tools like this:
perl Makefile.PL PREFIX=/path_to_your_home \
INSTALLPRIVLIB=/path_to_your_home/lib/perl5 \
INSTALLSCRIPT=/path_to_your_home/bin \
INSTALLSITELIB=/path_to_your_home/lib/perl5/site_perl \
INSTALLBIN=/path_to_your_home/bin \
INSTALLMAN1DIR=/path_to_your_home/man \
INSTALLMAN3DIR=/path_to_your_home/man3
make
make test
make install
(in some cases perl Makefile.PL PREFIX=/path_to_your_home would be sufficient)
Then, each time you want to use modules in that path, you should add this to your scripts as the second line:
use lib qw(/path_to_your_home/lib/perl5 /path_to_your_home/lib/perl5/site_perl);This line instructs Perl 5 to look for libraries in that directory as well as the standard directories.
Also consider using the wonderful CPAN.pm module to install and upgrade the perl modules available at CPAN (see www.perl.com/CPAN). If you have perl5.004 or higher you have it bundled with your distribution. Otherwise, download it from CPAN. When you install it the first time, it asks you a few questions; one of them is a PREFIX directory name as above. After configuration is over, you run it like so:
% perl -MCPAN -e shell > install CGIThis will fetch the latest CGI module, unpack it, make it, test it and install it into your local area or any other directory you instruct it to!
More CPAN.pm tricks:
> i /CGI/Returns the list of modules that match that pattern. Many other functions are also available.
Previous | Next | Table of Contents
Follow us on Twitter | Contact Us
Copyright 1994-2012 Boutell.Com, Inc. All Rights Reserved.