Prelbrew安裝教學

升級 perl 版本時,剛好瞄到這個Perlbrew官網,說不定以後會用到就順便來安裝看看,Perlbrew 可以幫你安裝及管理多種Perl版本。

環境:
VM:VMware Player 5.0
OS:CentOS 6.5(2.6.32-431.el6.i686)
gcc-4.4.7-4
perl-5.10.1

安裝必要套件:gcc-c++、perl-CPANPLUS

# yum install -y gcc-c++ perl-CPANPLUS

CPANPLUS 是一個能夠幫你輕鬆安裝 CPAN 模組的工具,請依下列順序安裝。

CPANPLUS::Dist::Build  //安裝完後要重啟 CPANPLUS 才會生效
YAML
MLDBM
version
Test::Pod
Package::Generator
File::ReadBackwards
PAR::Dist
Archive::Tar
IO::Zlib
Data::OptList
Test::Fatal
Test::Requires
Module::Implementation
Package::Stash
Test::Spec
Test::Deep
Test::Trap
Data::Dump
ExtUtils::Constant
:若模組安裝失敗可能與目前perl的版本有關,可至CPAN Testers Matrix查詢。

範例:除了CPANPLUS::Dist::Build安裝完後要重啟CPANPLUS以外,其餘模組可以用參數i一直安裝。 # cpanp
CPAN Terminal> i CPANPLUS::Dist::Build
  Installing CPANPLUS::Dist::Build (0.76)

  Module 'CPANPLUS::Dist::Build' requires 'ExtUtils::MakeMaker' to be installed

  If you don't wish to see this question anymore
  you can disable it by entering the following commands on the prompt:
   's conf prereqs 1; s save'

   1> Yes
   2> No
   3> Yes to all (for this module)
   4> No to all (for this module)

  Should I install this module? [1]: 3 //選3安裝所有相關的模組,如果不想每次都被問,可設定預設值,請參照設定1。
  ...安裝中
  Module 'CPANPLUS::Dist::Build' installed successfully
  No errors installing all modules
CPAN Terminal> q //離開CPANPLUS
#
# instmodsh //查詢已安裝模組
  Available commands are:
     l - List all installed modules
     m - Select a module
     q - Quit the program
cmd? l
   Archive::Tar
   CPAN::Perl::Releases
   CPANPLUS::Dist::Build
  ...略
cmd? q
#

透過CPANPLUS安裝及初始化Perlbrew

CPAN Terminal> i App::perlbrew
  ...安裝中
  Module 'App::perlbrew' installed successfully
  No errors installing all modules
CPAN Terminal> q

Exiting CPANPLUS shell
# perlbrew init
  perlbrew root (~/perl5/perlbrew) is initialized.

  Append the following piece of code to the end of your ~/.bash_profile and start a
  new shell, perlbrew should be up and fully functional from there:

     source ~/perl5/perlbrew/etc/bashrc

  Simply run `perlbrew` for usage details.

  Happy brewing!

# source ~/perl5/perlbrew/etc/bashrc

使用下列指令可以查看現有哪些版本的 Perl 可以供安裝,所以還不能直接使用。

# perlbrew available
  perl-5.19.9
  perl-5.18.2
  perl-5.16.3
  perl-5.14.4
  perl-5.12.5
  perl-5.10.1
  perl-5.8.9
  perl-5.6.2
  perl5.005_04
  perl5.004_05
  perl5.003_07

安裝 perl-5.14.4

# perlbrew install perl-5.14.4
  Fetching perl 5.14.4 as /root/perl5/perlbrew/dists/perl-5.14.4.tar.bz2
  Download http://www.cpan.org/src/5.0/perl-5.14.4.tar.bz2 to /root/perl5/perlbrew/dists/perl-5.14.4.tar.bz2
  Installing /root/perl5/perlbrew/build/perl-5.14.4 into ~/perl5/perlbrew/perls/perl-5.14.4

  This could take a while. You can run the following command on another shell to track the status:

    tail -f ~/perl5/perlbrew/build.perl-5.14.4.log  //觀察安裝過程

  perl-5.14.4 is successfully installed.

# perlbrew list  //查詢已安裝版本
  perl-5.14.4
# perl -v
  This is perl, v5.10.1 (*) built for i386-linux-thread-multi  //系統預設版本
# perlbrew switch perl-5.14.4
# perl -v
  This is perl 5, version 14, subversion 4 (v5.14.4) built for i686-linux  //切換後目前系統版本
# perlbrew off  //回到系統預設版本
注意!若直接從5.10.1升級至最新版本會失敗。



設定1

CPAN Terminal> s conf prereqs 3

  Key 'prereqs' was set to '3'
CPAN Terminal> s save

  Configuration successfully saved to CPANPLUS::Config::User      (/root/.cpanplus/lib/CPANPLUS/Config/User.pm)

模組來源設定

# cpanp
CPAN Terminal> s reconfigure

=================> MAIN MENU <=================

Welcome to the CPANPLUS configuration. Please select which
parts you wish to configure

Defaults are taken from your current configuration.
If you would save now, your settings would be written to:

  CPANPLUS::Config::User

  1> Select Configuration file
  2> Setup CLI Programs
  3> Setup CPANPLUS Home directory
  4> Setup FTP/Email settings
  5> Setup basic preferences
  6> Setup installer settings
  7> Select mirrors
  8> Edit configuration file
  9> Save & exit
  10> Quit without saving

Section to configure: [1]: 7

I see you already have some hosts selected:

ftp://ftp.cpan.org/pub/CPAN/
http://www.cpan.org/
ftp://ftp.nl.uu.net/pub/CPAN/
ftp://cpan.valueclick.com/pub/CPAN/
ftp://ftp.funet.fi/pub/languages/perl/CPAN/

If you'd like to stick with your current settings, just select 'Yes'.
Otherwise, select 'No' and you can reconfigure your hosts

Would you like to keep your current hosts? [Y/n]: n 是否保留原設定

Now we need to know where your favorite CPAN sites are located. Make a
list of a few sites (just in case the first on the array won't work).

If you are mirroring CPAN to your local workstation, specify a file:
URI by picking the CUSTOM option.

Otherwise, let us fetch the official CPAN mirror list and you can pick
the mirror that suits you best from a list by using the MIRROR option;
First, pick a nearby continent and country. Then, you will be presented
with a list of URLs of CPAN mirrors in the country you selected. Select
one or more of those URLs.

Note, the latter option requires a working net connection.

You can select VIEW to see your current selection and QUIT when you are done.

  1> Mirror
  2> Custom
  3> View
  4> Quit

Please choose an option [1]: 1
Now, we are going to fetch the mirror list for first-time configurations.
This may take a while...

  1> Africa
  2> Asia
  3> Europe
  4> North America
  5> Oceania
  6> South America
  7> Custom
  8> Up
  9> Quit

Pick a continent [4]: 2

  1> China
  2> India
  3> Indonesia
  4> Iran
  5> Israel
  6> Japan
  7> Kazakhstan
  8> Pakistan
  9> Republic of Korea
  10> Singapore
  11> Taiwan
  12> Thailand
  13> Turkey
  14> Viet Nam
  15> Custom
  16> Up
  17> Quit

Pick a country [1]: 11

You can enter multiple sites by seperating them by a space.
For example:
  1 4 2 5

  1> ftp://cpan.cdpa.nsysu.edu.tw
  2> ftp://cpan.nctu.edu.tw
  3> ftp://ftp.stu.edu.tw
  4> http://cpan.cdpa.nsysu.edu.tw
  5> http://cpan.nctu.edu.tw
  6> http://cpan.stu.edu.tw
  7> Custom
  8> View
  9> Up
  10> Quit

Please pick a site: 1 2 3
Host 'ftp://cpan.cdpa.nsysu.edu.tw' already selected

Selected ftp://cpan.cdpa.nsysu.edu.tw 1 host selected thus far.
Selected ftp://cpan.nctu.edu.tw 2 hosts selected thus far.
Selected ftp://ftp.stu.edu.tw 3 hosts selected thus far.

You can enter multiple sites by seperating them by a space.
For example:
  1 4 2 5

  1> ftp://cpan.cdpa.nsysu.edu.tw
  2> ftp://cpan.nctu.edu.tw
  3> ftp://ftp.stu.edu.tw
  4> http://cpan.cdpa.nsysu.edu.tw
  5> http://cpan.nctu.edu.tw
  6> http://cpan.stu.edu.tw
  7> Custom
  8> View
  9> Up
  10> Quit

Please pick a site:10

Your host configuration has been saved

=================> MAIN MENU <=================

Welcome to the CPANPLUS configuration. Please select which
parts you wish to configure

Defaults are taken from your current configuration.
If you would save now, your settings would be written to:

  CPANPLUS::Config::User

  1> Select Configuration file
  2> Setup CLI Programs
  3> Setup CPANPLUS Home directory
  4> Setup FTP/Email settings
  5> Setup basic preferences
  6> Setup installer settings
  7> Select mirrors
  8> Edit configuration file
  9> Save & exit
  10> Quit without saving

Section to configure: [1]: 9

沒有留言:

張貼留言