cpanm安装及Perl模块安装教程
cpanm是安装perl模块的最方便的方法。自动下载安装依赖包。使用cpan shell或下载源码包安装模块,遇到大量依赖关系,非常头痛。下面就是一例:
安装mongodb模块
# perl makefile.pl
warning: prerequisite class::method::modifiers 0 not found.
warning: prerequisite data::types 0 not found.
warning: prerequisite datetime 0 not found.
warning: prerequisite datetime::tiny 0 not found.
warning: prerequisite extutils::makemaker 6.59 not found. we have 6.30.
warning: prerequisite file::slurp 0 not found.
warning: prerequisite file::temp 0.17 not found. we have 0.16.
warning: prerequisite json 0 not found.
warning: prerequisite moose 0 not found.
warning: prerequisite test::exception 0 not found.
warning: prerequisite test::warn 0 not found.
warning: prerequisite tie::ixhash 0 not found.
warning: prerequisite try::tiny 0 not found.
warning: prerequisite boolean 0 not found.
writing makefile for mongodb
1. 安装cpanm
cpanm其实是一个可执行文件而已。将它下载到bin目录,然后添加执行权限就可以了。
# wget http:
//xrl.us/cpanm -o /usr/bin/cpanm; chmod +x /usr/bin/cpanm
2. 使用cpanm安装模块
# cpanm -h
-v,--verbose turns on chatty output
-q,--quiet turns off the most output
--interactive 开启交互配置(required for task:: modules)
-f,--force 强制安装
-n,--notest do not run unit tests
--test-only 只测试不安装
-s,--sudo sudo to run install commands
--installdeps 只安装依赖模块
--showdeps 只显示依赖信息
--reinstall 重新安装
--mirror 指定镜像url (e.g. http://cpan.cpantesters.org/)
--mirror-only 只从镜像下载
--prompt prompt when configure/build/test fails
-l,--local-lib specify the install base to install modules
-l,--local-lib-contained specify the install base to install all non-core modules
--self-contained install all non-core modules, even if they're already installed.
--auto-cleanup number of days that cpanm's work directories expire in. defaults to 7
examples:
cpanm test::more # install test::more
cpanm miyagawa/plack-0.99_05.tar.gz # full distribution path
cpanm http://example.org/lds/cgi.pm-3.20.tar.gz # install from url
cpanm ~/dists/mycompany-enterprise-1.00.tar.gz # install from a local file
cpanm --interactive task::kensho # configure interactively
cpanm . # install from local directory
cpanm --installdeps . # install all the deps for the current directory
cpanm -l extlib plack # install plack and all non-core deps into extlib
cpanm --mirror http://cpan.cpantesters.org/ dbi # use the fast-syncing mirror
参数名直接为模块名称
如,安装mongodb模块
# cpanm mongodb
--> working on mongodb
fetching http://www.cpan.org/authors/id/f/fr/friedo/mongodb-0.702.0.tar.gz ... ok
configuring mongodb-0.702.0 ... ok
==> found dependencies: datetime, tie::ixhash, data::types, datetime::tiny, class::method::modifiers, boolean, moose, file::slurp, try::tiny, test::exception, extutils::makemaker, test::warn, file::temp, json
--> working on datetime
...... //自动解决依赖模块
为了加快下载速度, 可以指定使用镜像,并只从镜像下载:
# cpanm --mirror http:
//mirrors.163.com/cpan --mirror-only mongodb
3. 删除模块
安装app::pmuninstall模块:
# cpanm app::pmuninstall
4.删除模块
# pm-uninstall mongodb
mongodb.so: undefined symbol: heutf8 问题解决方案参见:https://www.jb51.net/article/56285.htm
推荐阅读
-
逍遥安卓模拟器怎么用?逍遥安卓模拟器安装及使用教程图文详解
-
影音先锋xfplay下载安装及配置图文教程
-
ARC Welder怎么用 The App Runtime for Chrome下载及安装使用图文教程
-
CentOS安装mysql5.7 及简单配置教程详解
-
Adobe Dimension CC 2018中文安装及破解详细教程(附破解补丁下载)
-
alias sketchbook pro怎么用?alias sketchbook pro中文版安装及使用图文教程
-
eclipse和myeclipse安装教程及eclipse汉化教程(图文)
-
ogre3d环境配置 SDK安装配置及简单事例教程
-
PS磨皮滤镜软件Portraiture3汉化安装教程及使用方法图解(附下载)
-
mysql 5.7以上版本下载及安装图文教程