Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Senior Member jalal's Avatar
    Join Date
    May 2003
    Location
    Germany
    Posts
    1,377

    Default Installing Perl modules with CPAN

    There have been a lot of questions about how to install or update Perl modules with the CPAN interface, I decided to write up the instructions on doing it. If anyone wants to follow along with them (and be a guinea pig ) then here they are. Give me feedback and when its ready I'll put them up on my site:

    ============
    Installing Perl Modules on Westhost.

    Perl makes a lot of use of library modules, which can be installed and updated separately from the Perl program itself. These modules are normally installed using CPAN (itself a Perl module) which is used to automate the process of connecting to CPAN server and downloading, make'ing and installing the modules. On most servers, this is done as the root user, because a base Perl installation is normally owned by root. However on Westhost, we don't have root privileges so we need to take some extra steps to install the modules elsewhere. What follows is a method of doing that.
    CPAN stands for the Comprehensive Perl Archive Network and more information on it can be found at http://www.cpan.org/

    Before starting you need to make sure that you have the GCC Compiler Collection installed, this is needed and without it Perl will still run but building of the modules will probably (but not certainly) fail. And remember, you are messing with the server system, if you're not comfortable with doing this, don't!

    Because we don't have root privileges to install or update the Perl modules, we need to install the modules elsewhere, in a directory that we have access to. In addition to installing the modules, we also need to tell Perl where the extra libraries are installed so that Perl can find them when running. We are going to create a directory '/perl5lib' and use that for the installations. You can call the directory what you want and install it wherever you like as long as you have write permission for it. In the following I will assume it is '/perl5lib'.

    First, you need to start up the CPAN modules, this is done by typing:
    $ perl -MCPAN -e shell
    or, alternatively:
    $ cpan

    The cpan shell will then realize that this is the first time it has been called and ask if you want to do a manual configuration. You do, so answer yes. If you have already run cpan before and configured it, see below for modifying the configuration.
    All the questions have default answers and you can just hit enter to accept the default, until you reach a question like:
    "Parameters for 'perl Makefile.PL' command?"
    Here you want to enter the following:
    PREFIX=/perl5lib LIB=/perl5lib/lib INSTALLMAN1DIR=/perl5lib/man1 INSTALLMAN3DIR=/perl5lib/man3

    Accept the defaults for the next few questions until you are asked for your favorite mirrors. You want to choose mirrors in North America/United States and then select some mirrors.

    Once that is done, continue with the defaults to any questions until you are back at the cpan prompt and then type quit.

    If you have run cpan before and configured it and need to change the configuration, then do this:
    $ cpan
    cpan>o conf
    cpan>o conf makepl_arg PREFIX=/perl5lib LIB=/perl5lib/lib INSTALLMAN1DIR=/perl5lib/man1 INSTALLMAN3DIR=/perl5lib/man3
    cpan> quit

    So, now we have told CPAN about our new directory, we need to tell the system about it as well. For this you need to enter the following line in your .bashrc file:
    export PERL5LIB=/perl5lib/lib

    Save the file, and log off the SSH session. Then log back in again.

    Now we are ready to try installing a module. A good test of the system is to install an update for the CPAN modules itself. Start cpan
    $ cpan
    cpan> install Bundle::CPAN

    There will then be a flurry of activity, possibly a few warnings until you get a question about 'unsatisfied dependencies'. Answer 'yes' to have them installed as well (the dependencies might vary, but on my system CPAN also installed Digest::MD5 and File::Spec). There will be a lot more text scrolling by until you finally get a success message and you are returned to the prompt.
    Next, reload cpan with:
    cpan>reload cpan
    and, assuming that was successful, you should be able to install the modules that you need.

    ============

  2. #2
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,721

    Default WeeHee

    Thank You, Thank You, Thank You, Thank You, Thank You, Thank You,

    I have been struggleing with all this and just did not know the right questions to ask.

    I ran the cpan so well now have to go back and configure it. I do have a couple comments. I think I know ways on how to this or at least check int the forums to find how to edit a file using pico? in SSH but if you are doing this as a tutorial pehaps a link to that explenation would be good in that area.
    So, now we have told CPAN about our new directory, we need to tell the system about it as well. For this you need to enter the following line in your .bashrc file:
    export PERL5LIB=/perl5lib/lib

    Save the file, and log off the SSH session. Then log back in again.
    The next question is that I have installed Bundle::CPAN (with out the special config and setup) and I belive it did update some stuff but that maybe I could use the .bashrc file to tell the system where they are. I well try to look and see if I can find an example of what I am talking about.

    Thank you again Jalal for this. I can't wait to try it out.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  3. #3
    Senior Member jalal's Avatar
    Join Date
    May 2003
    Location
    Germany
    Posts
    1,377

    Default Re: WeeHee

    Quote Originally Posted by wildjokerdesign
    I do have a couple comments. I think I know ways on how to this or at least check int the forums to find how to edit a file using pico? in SSH but if you are doing this as a tutorial pehaps a link to that explenation would be good in that area.
    Pico is pretty simple, it shouldn't take too long to figure out. VI is much better though.

    Quote Originally Posted by wildjokerdesign
    Thank you again Jalal for this. I can't wait to try it out.
    Let me know what doesn't work...
    :P

  4. #4
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,721

    Default

    Hi Jalal,

    Decided to try the reconfigure part since I had already installed CPAN

    I went in to SSH and started up CPAN
    I then typed the first command
    cpan>o conf

    I got
    CPAN::Config options from /usr/local/perl/lib/5.6.0/Config.pm:
    It then list the configuration of each thing these are a few of the paths it listed.

    build_dir /home/username/.cpan/build
    cpan_home /home/username/.cpan
    keep_source_where /home/username/.cpan/sources

    the others are for like ftp, shell, tar, zip... I think those do not matter are set the same no matter what.

    Ok the reason I listed this is when I check permissions and such there are two dirctories concerning perl

    /usr/local/perl/lib/5.6.0/
    /usr/local/perl/lib/site_perl/5.6.0/

    The first one seems to be owned by root for the most part and has the Config.pm

    The second one seems to be owned by user and does not have the Config.pm. I can change stuff in that directory i.e the permission on things. I can't do that in the first dirctory.

    I went ahead and stopped in the process to ask if perhaps I should use this second directory instead of setting up another one. The only thing drawback I can see it that the man and lib dirctories are back up the line at /usr/local/perl the premission on each are
    drwxrwxr-t 4 root vuser 4096 Jan 26 18:09 lib
    drwxrwxr-t 4 username vuser 4096 Jan 26 18:09 man

    It may just be easier to start clean but didn't want to get a bunch of duplicate directories and files all over the place. In the examples above I have used username where it is really my true username that I am logged in as.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  5. #5
    Senior Member jalal's Avatar
    Join Date
    May 2003
    Location
    Germany
    Posts
    1,377

    Default

    I would not try to mess with what is already installed on the server, for two reasons:
    1. its hard to predict what is going to be writable and what isn't
    2. westhost is going to overwrite a bunch of stuff if they ever do an upgrade.

    As for duplicate files, yes, its a pity, but I think the directories listed in the PERL5LIB variable are read instead of the already installed ones.

    I didn't mention it, but a clean way of starting up afresh is to delete the whole of /home/username/.cpan before running cpan, then you will get a fresh configuration.

    HTH

  6. #6
    Senior Member FZ's Avatar
    Join Date
    May 2003
    Location
    Johannesburg, South Africa
    Posts
    1,024

    Default

    Supremely useful - just like everything else on your wonderful site. Excellent work, Tim! I just have a question (and something to contribute): as I said in my PM to you, I could not get DB_File installed - nor could I get BerkeleyDB - will using our own custom directory have any effect on this? Would it also allow one to install SpamAssassin (i.e. 2.63) with no problems? I know I could test this all myself, but I ask you so that you can clarify it - and post that clarification along with this tutorial (e.g. a "what this will do", "what this won't do" kind of thing). And now for my "contribution": deleting /home/username/.cpan just removes the "install files" of modules I have downloaded - it does not seem to reset my CPAN config...
    Fayez Zaheer

  7. #7
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,721

    Default

    Just a quick update of where I am on this. The first try is on hold for the moment. When I went to edit the .bashrc I was not able to since it is still owned by root. This is on one of my new accounts that I installed via my resellers account. Did some checking and some of my older accounts have already been switched and vuser has permission to edit .bashrc

    So the bottom line is if for some reason you do not have access you need to call Support and ask them to change if for you. Just got off the phone with them and they said it would take about an hour for the system manager to get it done. I went ahead and had them change it on my other accounts while they where at it. So check the permissions on your .bashrc first and if vuser does not have access give the a call.

    The support guy said that they are working on getting the default switched but till they do when new accounts are created root still owns .bashrc (at least with a resellers account)
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  8. #8
    Senior Member FZ's Avatar
    Join Date
    May 2003
    Location
    Johannesburg, South Africa
    Posts
    1,024

    Default

    Shawn,

    There is a way to do the .bashrc thing yourself, check it out: http://forums.westhost.com/phpBB2/vi...hp?p=8688#8688
    Fayez Zaheer

  9. #9
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,721

    Default

    Thanks Fayez! I knew I had read something about it somewhere but could not find it or remember it. For the moment I well leave things as they are since they are changeing it but well keep that in mind for the future.
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

  10. #10
    Moderator wildjokerdesign's Avatar
    Join Date
    Jun 2003
    Location
    Kansas City Mo
    Posts
    5,721

    Default

    Fayez,

    If you remove the Config.pm from /usr/local/perl/lib/5.6.0/CPAN the it well give a fresh start. Make sure to leave the other files and directory there. If you delete the entire directory then you have to go get it back from one of your other accounts and upload it again... I know this
    Shawn
    Please remember your charity of choice: http://www.redcross.org

    Handy Links: wildjokerdesign.net | Plain Text Editors: EditPlus | Crimson

Similar Threads

  1. Installing Perl GD module with CPAN
    By sonavor in forum CGI Scripts / Perl
    Replies: 15
    Last Post: 10-12-2006, 03:12 AM
  2. Installing Bugzilla on a WestHost VPS
    By sonavor in forum CGI Scripts / Perl
    Replies: 0
    Last Post: 03-28-2006, 11:43 PM
  3. Installing Perl 5.8.7
    By JasonOdyssey in forum CGI Scripts / Perl
    Replies: 1
    Last Post: 10-14-2005, 01:14 AM
  4. problem installing a perl module
    By drgandy in forum CGI Scripts / Perl
    Replies: 1
    Last Post: 01-26-2005, 06:52 AM
  5. Problem Updating Perl Modules
    By Jerry in forum CGI Scripts / Perl
    Replies: 6
    Last Post: 11-08-2003, 11:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •