インストールする(その9)
mod_perl 1.29をインストールする
mod_perl 1.29のインストールを以下の手順で行う。
$ wget http://perl.apache.org/dist/mod_perl-1.29.tar.gz $ tar zxvf mod_perl-1.29.tar.gz $ cd mod_perl-1.29 $ perl Makefile.PL USE_APXS=1 WITH_APXS=/usr/local/apache/bin/apxs EVERYTHING=1
ここで以下のメッセージが表示される。
: : Checking for LWP::UserAgent......failed Can't locate LWP/UserAgent.pm in @INC (@INC contains: ...) at Makefile.PL line 1157. The libwww-perl library is needed to run the test suite. Installation of this library is recommended, but not required. Checking for HTML::HeadParser....failed Can't locate HTML/HeadParser.pm in @INC (@INC contains: ...) at Makefile.PL line 1175. The HTML-Parser package is needed (by libwww-perl) to run the test suite. : :
どうやら、libwww-perlなるものをインストールした方が良いらしい。
libwww-perlの正体はBundle::LWPなのでこれをCPANでインストールする。
# cpan cpan> install Bundle::LWP : : cpan> quit
CPANのメッセージにしたがってlibwww-perlとその関連モジュールをインストールする。
もう一度、mod_perlのインストール作業に戻ろう。
$ perl Makefile.PL USE_APXS=1 WITH_APXS=/usr/local/apache/bin/apxs EVERYTHING=1 $ make $ make test Can't make test with APXS (yet) $ su # make install
後はmod_perlのマニュアルを参考にして、/usr/local/apache/conf/httpd.confにハンドラの設定を行えば良い。
LoadModule perl_module libexec/libperl.so AddModule mod_perl.c <IfModule mod_perl.c> PerlModule Apache::Registry PerlModule Apache::PerlRun Alias /perl/ "/usr/local/apache/perl/" # なぜか、Location設定ではApache::Registryは動作しない。 <Directory "/usr/local/apache/perl/"> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI FollowSymlinks Allow from all PerlSendHeader On </Directory> Alias /cgi-perl/ "/usr/local/apache/perl/" <Location /cgi-perl> SetHandler perl-script PerlHandler Apache::PerlRun Options ExecCGI FollowSymlinks Allow from all PerlSendHeader On </Location> <Files */nph-*> PerlSendHeader Off </Files> </IfModule>
試すために/usr/local/apache/perl/ptest.cgiを以下の内容で作成し実行属性を付ける。
#!/usr/bin/perl print "Content-type: text/plain\n"; print "\n"; foreach $key (keys %ENV) { printf("\"%s\"=\"%s\"\n", $key, $ENV{$key}); }
そして、以下のアドレスをブラウザで表示する。
http://comomonga:8080/perl/ptest.cgi http://comomonga:8080/cgi-perl/ptest.cgi