16 October 2013

Installing perl in a User Directory


Here is the procedure that I went thru to add perl into a user directory:

  1. Setup the directories:
    • cd 
    • mkdir perl5 
    • mkdir perl5/bin 
    • mkdir perl5/lib 
    • mkdir perl5/man 
    • mkdir perl5/man/man1 
  2. Download the source (See this link for URLs: http://www.cpan.org/src/README.html)
    • wget http://www.cpan.org/src/5.0/perl-5.10.1.tar.gz 
  3. Unpack it
    • tar zxvf perl-5.10.1.tar.gz 
  4. Install it
    • cd perl\-5.10.1 
    • ./Configure -des -Dusethreads -Dprefix=$HOME/perl5
    • make test && make install 
  5. Configure PERL5LIB (add to .profile)
    • export PERL5LIB=$HOME/perl5:$HOME/perl5/site_perl 
  6. Install cpanm
    • $HOME/perl5/bin/cpan App::cpanminus 
  7. Install LWP
    • $HOME/perl5/bin/cpanm LWP 

Install XML::Parse and Expat:

  1. Download Expat: http://sourceforge.net/projects/expat/files/expat/
    • wget http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz/download 
  2. Compile Expat
    • tar -zxvf expat-2.1.0.tar.gz 
    • cd expat-2.1.0 
    • ./configure --prefix=$HOME/usr 
    • make 
    • make install 
  3. Install XML::Parser
    • cd 
    • perl5/bin/cpan 
    • o conf makepl_arg "EXPATLIBPATH=/prod/user/home/boz604/usr/lib EXPATINCPATH=/prod/user/home/boz604/usr/include" 
    • o conf commit 
    • install XML::Parser 
    • quit 

Install Net::SSLeay and OpenSSL and Zlib:

  1. Download OpenSSL
    • wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz 
  2. Compile OpenSSL
    • tar -zxvf openssl-1.0.1e.tar.gz 
    • cd openssl-1.0.1e 
    • ./config shared --prefix=$HOME/usr --openssldir=$HOME/usr/openssl
    • make 
    • make test && make install 
  3. Download Zlib
    • wget http://www.zlib.net/zlib-1.2.8.tar.gz 
  4. Compile Zlib
    • tar -zxvf zlib-1.2.8.tar.gz 
    • cd zlib-1.2.8 
    • ./configure --prefix=$HOME/usr 
    • make 
    • make test && make install 
  5. Install Net::SSLeay
    • cd 
    • OPENSSL_PREFIX=$HOME/usr perl5/bin/cpan Net::SSLeay 
  6. Install LWP::Protocol::https
    • cd 
    • perl5/bin/cpanm LWP::Protocol::https 

Here is how to set custom Include and Lib directories:

  •  In CPAN:
    • perl5/bin/cpan 
    • o conf makepl_arg "LIBS=-L$HOME/usr INC=-I$HOME/usr/include" 
    • o conf commit 
  • When running perl:
    • perl -I $HOME/perl5/lib/site_perl 
  • Inside your perl script
    • use lib "/home/user/perl5/lib/site_perl"; 


3 comments:

  1. Hello please how do I check my directory or should I just type same thing u wrote?I want to install in my windows and virtual box Linux?

    ReplyDelete
    Replies
    1. The above commands are all for linux. For checking a linux directory use the `ls` command.

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete