
CentOS8とcpanm(cpanminus)によるPerlモジュールの導入・環境構築
2020-10-303 min read
目次
- 概要
- cpanmについて
- cpanmのインストール-dnfでインストール
- cpanmのインストール-shell経由でインストール
- cpanmのインストール-cpan経由
- cpanmでcpanモジュールをインストール
- 参考にしたサイト
- おまけ-cpanmのオプション
概要
cpanm(cpanminus)を利用してCentOS8上にPerl環境を構築した際の記録です。
cpanmについて
App::cpanminus - get, unpack, build and install modules from CPAN - metacpan.org
CPANからモジュールの取得とビルド・インストールを行うライブラリです。
CPAN::shellでもモジュールのインストールはできますが、設定しやすさやパーフォマンス・権限等の問題からcpanmの方が扱いやすいと思いました。
cpanmのインストール (DNFでインストール)
CentOS8の場合は標準でRPMパッケージが用意されているためDNFでインストールします。
$ dnf install perl-App-cpanminus
$ which cpanm
/usr/bin/cpanm
cpanmのインストール (shell経由でインストール)
root権限が利用できない場合は次のような手順で設定していきます。
まずはcpanmをインストールします。環境変数PERL_CPANM_OPT
はCPANモジュールがインストールされるディレクトリを指定します。
$ export PERL_CPANM_OPT="--local-lib=~/perl5"
$ curl -L -O http://xrl.us/cpanm
$ perl cpanm App::cpanminus
PATHを通します。
$ export PATH=$HOME/perl5/bin:$PATH;
$ which cpanm
~/perl5/bin/cpanm
cpanmのインストール (cpan経由)
CPANが利用できる場合はCPANコマンドを利用してcpanmをインストールもできます。
$ cpan App::cpanminus
cpanmでCPANモジュールをインストール
試しにJSONモジュールをインストールします。
$ cpanm JSON
--> Working on JSON
Fetching http://www.cpan.org/authors/id/I/IS/ISHIGAKI/JSON-4.02.tar.gz ... OK
Configuring JSON-4.02 ... OK
Building and testing JSON-4.02 ... OK
Successfully installed JSON-4.02
2 distributions installed
ローカルに配置したファイルもインストールできます。
$ cpanm /home/foo/YAML-1.30.tar.gz
インストールするディレクトリを指定してインストールもできます。以下のコマンドの場合は~/test
にインストールされます。
$ cpanm YAML -L ~/test
参考にしたサイト
cpanm - CPANからモジュールを取得、アンパック、インストールする
おまけ cpanmのオプション
Options:
-v,--verbose Turns on chatty output
-q,--quiet Turns off the most output
--interactive Turns on interactive configure (required for Task:: modules)
-f,--force force install
-n,--notest Do not run unit tests
--test-only Run tests only, do not install
-S,--sudo sudo to run install commands
--installdeps Only install dependencies
--showdeps Only display direct dependencies
--reinstall Reinstall the distribution even if you already have the latest version installed
--mirror Specify the base URL for the mirror (e.g. http://cpan.cpantesters.org/)
--mirror-only Use the mirror's index file instead of the CPAN Meta DB
-M,--from Use only this mirror base URL and its index file
--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
Commands:
--self-upgrade upgrades itself
--info Displays distribution info on CPAN
--look Opens the distribution with your SHELL
-U,--uninstall Uninstalls the modules (EXPERIMENTAL)
-V,--version Displays software version
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
cpanm -M https://cpan.metacpan.org App::perlbrew # use only this secure mirror and its index
You can also specify the default options in PERL_CPANM_OPT environment variable in the shell rc:
export PERL_CPANM_OPT="--prompt --reinstall -l ~/perl --mirror http://cpan.cpantesters.org"
Type `man cpanm` or `perldoc cpanm` for the more detailed explanation of the options.
Recommends
CentOS8とcpanm(cpanminus)によるPerlモジュールの導入・環境構築
2020-10-30
CentOS7 に Perl + CPAN 環境を構築
2019-11-17
CentOS7 に Perl環境を構築する
2019-11-16
[Perl] CentOS8 に plenv をインストール
2021-06-05
CentOS8にDNFでPerl5.30のインストール
2020-12-22
AutotoolsでconfigureやMakefileの作成
2022-01-10
RPMパッケージ作成 Dockerを利用して
2022-01-10
CentOS8/RHEL8でのRPM管理における検討事項
2021-12-01
RPMのspecファイルで利用するマクロ・変数
2022-01-09
CentOS8 に Python + OpenCV をインストール
2021-06-05
CentOS6(Docker)でyum update できなくなった
2021-05-20
PostfixでメールリレーしてMailHogで受信する開発用Dockerコンテナの構築
2021-05-19
Perlでconstant(定数)をhashのキーに使う
2021-04-19
php-fpmのステータスページを表示 Apache & htaccess
2021-03-24
CentOS8 に Oracle12.2 clientをインストールする
2021-03-07
New Posts
Prisma MySQL でUTC以外の任意のタイムゾーンを利用するのが難しい件
2022-08-08
Prisma TypeScript MySQLなプロジェクトの構築
2022-08-08
Prisma TypeScript SQLiteなプロジェクトの構築
2022-08-06
[AWS]Lambda vs Fargate. APIを実装する場合に思うこと
2022-07-30
macOSにzigをインストールしてHello World!する
2022-07-18
[AWS CDK] Cognito の OIDC プロバイダに Auth0 を設定
2022-07-03
Amazon S3 でライフサイクルポリシーを設定する
2022-06-19
AWS Certified Developer Associate に合格した
2022-06-19
Fisher-Yates shuffleで配列シャッフル [js/ts/php]
2022-06-19
JavaScriptでUTF-16コードを文字列に変換
2022-06-18
[JS]乱数でランダムな整数を生成する
2022-06-18
[JS]BigIntでMathが使えない件
2022-06-12
AWS SAPに合格しました
2022-06-11
[AWS]DataSync/Storage Gateway/Transfer Family...
2022-05-29
[AWS CDK]ECS FargateでNestJSで作成したRESTfull APIデ...
2022-05-24
Hot posts!
Proxy環境下でcurlを実行する
2019-12-07
OpenCVのMatのタイプ一覧表
2018-11-25
Macでも利用できるDBクライアント MySQL PostgreSQL Oracle など
2019-12-21
TablePlusを使ってみる。シンプルでモダンなSQLクライアントツール
2018-09-30
DBクライアントツールはDBeaverをおすすめしたい
2021-03-08
AWS S3のアクセスキーIDとシークレットアクセスキーの取得 作業用ユーザを作成
2019-06-12
AtCoderで初めて色がつくまでの話(茶色) レートが中々上がらなかった原因
2018-11-25
CentOS8でEPELとPowerToolsリポジトリの有効化
2020-11-30
Macでターミナルからポートスキャンを行う方法。
2018-12-09
Python + OpenCVのfillConvexPolyで複雑なポリゴンを描画する
2018-11-27
Date
▶︎
2022 年 (37)
▶︎
2021 年 (40)
▶︎
2020 年 (30)
▶︎
2019 年 (90)
▶︎
2018 年 (89)
▶︎
2017 年 (1)
Tags
Author