一般來說,安裝perl模塊常見有源碼、CPAN命令、包管理工具等三種方法,本文以安裝Net::Telnet模塊為例,簡單的介紹一下這三種方法。
第一種,直接去CPAN官網(wǎng)下載源碼包安裝,詳細(xì)的安裝方法等,請參照解壓目錄下的README或者INSTALL文件:
1 2 3 4 5 6 | [root@ test ~] # wget http://search.cpan.org/CPAN/authors/id/J/JR/JROGERS/Net-Telnet-3.03.tar.gz [root@ test ~] # tar -xzvf Net-Telnet-3.03.tar.gz [root@ test ~] # cd Net-Telnet-3.03 [root@ test Net-Telnet-3.03] # perl Makefile.PL [root@ test Net-Telnet-3.03] # make && make test [root@ test Net-Telnet-3.03] # make install |
在有的模塊的安裝過程中,可能會詢問一些設(shè)置情況,根據(jù)你的實際情況選擇。
注意,如果源碼包安裝過程中出現(xiàn)了依賴別的模塊的情況,需要先安裝依賴的模塊,所以源碼安裝有時候比較麻煩。
第二種,用cpan命令在線安裝,安裝的時候模塊名一定要正確:
1.首先安裝一些cpan需要的一些小工具:
2.然后開始用cpan命令安裝,第一次用cpan命令會有很多要設(shè)置的,為了簡單,除了下面列出來的,其他的我都采用默認(rèn),直接回車(更推薦你仔細(xì)閱讀每一步的提示信息,根據(jù)實際情況而進(jìn)行相應(yīng)的選擇):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | [root@ test ~] # cpan install Net::Telnet ......前略...... First, pick a nearby continent and country (you can pick several of each, separated by spaces, or none if you just want to keep your existing selections). Then, you will be presented with a list of URLs of CPAN mirrors in the countries you selected, along with previously selected URLs. Select some of those URLs, or just keep the old list. Finally, you will be prompted for any extra URLs -- file :, ftp :, or http: -- that host a CPAN mirror. (1) Africa (2) Asia (3) Central America (4) Europe (5) North America (6) Oceania (7) South America Select your continent (or several nearby continents) [] 2 <----選擇你所在的大區(qū)域(洲),然后回車 Sorry! since you don't have any existing picks, you must make a geographic selection. (1) Bangladesh (2) China (3) Hong Kong (4) India (5) Indonesia (6) Israel (7) Japan (8) Kazakhstan (9) Pakistan (10) Republic of Korea (11) Russia (12) Saudi Arabia (13) Singapore (14) Taiwan (15) Thailand (16) Turkey Select your country (or several nearby countries) [] 7 <----選擇你所在的國家,然后回車 Sorry! since you don't have any existing picks, you must make a geographic selection. (1) ftp : //ftp .dti.ad.jp /pub/lang/CPAN/ (2) ftp : //ftp .jaist.ac.jp /pub/CPAN/ (3) ftp : //ftp .kddilabs.jp /CPAN/ (4) ftp : //ftp .nara.wide.ad.jp /pub/CPAN/ (5) ftp : //ftp .riken.jp /lang/CPAN/ (6) ftp : //ftp .ring.gr.jp /pub/lang/perl/CPAN/ (7) ftp : //ftp .u-aizu.ac.jp /pub/CPAN/ (8) ftp : //ftp .yz.yamagata-u.ac.jp /pub/lang/cpan/ Select as many URLs as you like (by number), put them on one line, separated by blanks, e.g. '1 4 5' [] 2 4 5 <----選擇你所在的模塊下載 ftp 站點,然后回車 ......前略...... |
第三種,最簡單的方法,使用yum安裝:
但是只有yum源里有的perl模塊,才可以通過這種方式安裝,所以并不適合所有perl模塊。為了讓你的yum軟件倉庫里能有更多常用的軟件,建議你除了官方的yum源外,再追加配置EPEL和rpmforge等常見且可以信賴的yum源。
聯(lián)系客服