本資料はCentOSを使用して、CPAN環境を構築しました。
CentOS5, CentOS6ともに本資料の動作確認済みです。
htmlinsert(): The given local file does not exist or is not readable.
CentOS6をMinimalでインストールした場合など、Perlすらインストールされていません。
以下のコマンドで開発ツール一式(開発関連パッケージ)をインストールすることができます。
yum groupinstall 'Development tools'
本コマンドについては、以下の記事を参考にしてください。
CentOS6の場合は、インストール状態によってはCPANもインストールされていません。
以下のコマンドでcpanをインストールします。
yum install cpan
CPANを起動するには、以下のコマンドのいずれかを使用してください。
本コマンドは、rootで実行してください。
(Ubuntuなどであれば、sudoコマンドを使用し以下のコマンドを実行してください。)
cpan
または
perl -MCPAN -e shell
本資料では、以下cpanで起動した例を記します。
proxyサーバを利用しなけらばならない場合は、cpanコマンドによる初回問い合わせで入力してもよいのですが、環境変数 http_proxyとftp_proxy 設定しておけばCPAN初期設定画面に表示されます。
以下にhttp_proxy, ftp_proxyの設定例を記します。
export http_proxy=http://proxy_server:8080/ export ftp_proxy=http://proxy_server:8080/
書式は以下のようになります。
export http_proxy=http[s]://プロキシサーバ:ポート番号/ export ftp_proxy=http[s]://プロキシサーバ:ポート番号/
基本的にはデフォルトのままで設定が完了できます。
デフォルト値が[]内に表示されています。
デフォルト値のままでよいのであれば、Enterキーを押します。
[root@centos5 ~]# cpan We have to reconfigure CPAN.pm due to following uninitialized parameters: cpan_home, keep_source_where, build_dir, build_cache, scan_cache, index_expire, gzip, tar, unzip, make, pager, makepl_arg, make_arg, make_install_arg, urllist, inhibit_startup_message, ftp_proxy, http_proxy, no_proxy, prerequisites_policy, cache_metadata /usr/lib/perl5/5.8.8/CPAN/Config.pm initialized. CPAN is the world-wide archive of perl resources. It consists of about 100 sites that all replicate the same contents all around the globe. Many countries have at least one CPAN site already. The resources found on CPAN are easily accessible with the CPAN.pm module. If you want to use CPAN.pm, you have to configure it properly. If you do not want to enter a dialog now, you can answer 'no' to this question and I'll try to autoconfigure. (Note: you can revisit this dialog anytime later by typing 'o conf init' at the cpan prompt.) Are you ready for manual configuration? [yes]
当方はAsiaを選びました。
(1) Africa (2) Asia (3) Europe (4) North America (5) Oceania (6) South America Select your continent (or several nearby continents) []
日本を選びました。
(1) China (2) India (3) Indonesia (4) Israel (5) Japan (6) Kazakhstan (7) Pakistan (8) Republic of Korea (9) Saudi Arabia (10) Singapore (11) Taiwan (12) Thailand (13) Turkey (14) Viet Nam Select your country (or several nearby countries) []
ダウンロードするミラーが表示されるので使用するミラーを選択します。
(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' []
Config.pmが設定されたメッセージが表示されcpanプロンプトが表示されれば完了です。
quit<Enter>を入力すればcpanプロンプトが終了します。
commit: wrote /usr/lib/perl5/5.8.8/CPAN/Config.pm Terminal does not support AddHistory. cpan shell -- CPAN exploration and modules installation (v1.7602) ReadLine support available (try 'install Bundle::CPAN') cpan>
cpanコマンドを利用してArchive::Zipをインストールしてみます。
cpanに-iオプションをつけインストールしたいモジュールを入力しEnterキー押しました。
cpanコマンドについては、manコマンドなどで確認してみてください。
[root@centos5 ~]# cpan -i Archive::Zip CPAN: Storable loaded ok CPAN: LWP::UserAgent loaded ok <snip>
途中、問い合わせがあります。基本的にはデフォルト値で大丈夫です。
以下のようにCPANモジュールをインストール中にエラーが発生する場合があります。
<snip> Failed 12/15 test scripts, 20.00% okay. 13/13 subtests failed, 0.00% okay. make: *** [test_dynamic] エラー 255 /usr/bin/make test -- NOT OK Running make install make test had returned bad status, won't install without force
このような場合は前述に記した[[開発環境のパッケージ>]]をインストールすればほとんど解決するはずです。
Archive::Zipのインストールが完了メッセージは以下の通りです。
<snip> Installing /usr/share/man/man3/Archive::Zip.3pm Installing /usr/bin/crc32 Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Archive/Zip/.packlist Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod /usr/bin/make install -- OK [root@centos5 ~]#
CPANの初期設定を削除する方法を記します。
以下のコマンドをCPANプロンプトが表示されている状態で入力しEnterキーを押すと再設定できます。
設定変更の場合や設定ミスの場合、以下のコマンドでCPANの再設定を行ってください。
o conf init
上記コマンドでは、CPANの初期化をし再度設定画面がすぐに表示されます。
CentOSでしか確認していませんが、CPANの初期設定コマンドである o conf init を実行すると以下のメッセージが表示されました。
cpan> o conf init /usr/lib/perl5/5.8.8/CPAN/Config.pm initialized.
/usr/share/perl5/CPAN/Config.pm
このファイルを削除することにより、CPANの設定が初期化されます。
ちなみにConfig.pmには、以下のようになっています。
[root@centos5 ~]# cat /usr/lib/perl5/5.8.8/CPAN/Config.pm # This is CPAN.pm's systemwide configuration file. This file provides # defaults for users, and the values can be changed in a per-user # configuration file. The user-config file is being looked for as # ~/.cpan/CPAN/MyConfig.pm. $CPAN::Config = { 'build_cache' => q[10], 'build_dir' => q[/root/.cpan/build], 'cache_metadata' => q[1], 'cpan_home' => q[/root/.cpan], 'ftp' => q[/usr/kerberos/bin/ftp], 'ftp_proxy' => q[], 'getcwd' => q[cwd], 'gpg' => q[/usr/bin/gpg], 'gzip' => q[/bin/gzip], 'histfile' => q[/root/.cpan/histfile], 'histsize' => q[100], 'http_proxy' => q[], 'inactivity_timeout' => q[0], 'index_expire' => q[1], 'inhibit_startup_message' => q[0], 'keep_source_where' => q[/root/.cpan/sources], 'links' => q[/usr/bin/links], 'make' => q[/usr/bin/make], 'make_arg' => q[], 'make_install_arg' => q[], 'makepl_arg' => q[], 'ncftp' => q[], 'ncftpget' => q[], 'no_proxy' => q[], 'pager' => q[/usr/bin/less], 'prerequisites_policy' => q[ask], 'scan_cache' => q[atstart], 'shell' => q[/bin/bash], 'tar' => q[/bin/tar], 'term_is_latin' => q[1], 'unzip' => q[/usr/bin/unzip], 'urllist' => [], 'wget' => q[/usr/bin/wget], }; 1; __END__
htmlinsert(): The given local file does not exist or is not readable.