Perl日記

日々の知ったことのメモなどです。Perlは最近やってないです。

iMac(Mid 2011)にPerl5.14.1でmod_perl2.0.5を入れたメモ

タイトルのとおり入れてみたので未来の自分用。

$ curl -LO http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz
$ tar zxvf mod_perl-2.0-current.tar.gz
$ cd mod_perl-2.0.5/

apxsを使ってmod_*.soのところに入れてもらう。

$ which apxs
/usr/sbin/apxs
$ perl Makefile.PL MP_APXS=/usr/sbin/apxs
...
...
...
[warning] mod_perl dso library will be built as mod_perl.so
[warning] You'll need to add the following to httpd.conf:
[warning] 
[warning]   LoadModule perl_module modules/mod_perl.so
[warning] 
[warning] depending on your build, mod_perl might not live in
[warning] the modules/ directory.

[warning] Check the results of
[warning] 
[warning]   $ /usr/sbin/apxs -q LIBEXECDIR
[warning] 
[warning] and adjust the LoadModule directive accordingly.

ゆわれたとおり、チェックしてみる。

$ /usr/sbin/apxs -q LIBEXECDIR
/usr/libexec/apache2
$ cd /usr/libexec/apache2/
$ ls
mod_actions.so
...

モジュールあるところにちゃんとなってる。

$ make
$ make test
Test Summary Report
-------------------
t/api/err_headers_out.t               (Wstat: 0 Tests: 6 Failed: 3)
  Failed tests:  2-3, 5
t/apache/util.t                       (Wstat: 0 Tests: 8 Failed: 4)
  Failed tests:  1-4
t/filter/out_str_reverse.t            (Wstat: 0 Tests: 2 Failed: 1)
  Failed test:  2
t/api/request_rec.t                   (Wstat: 0 Tests: 55 Failed: 2)
  Failed tests:  13, 38
Files=242, Tests=2637, 92 wallclock secs ( 0.99 usr  0.66 sys + 65.26 cusr 10.57 csys = 77.48 CPU)
Result: FAIL
Failed 4/242 test programs. 10/2637 subtests failed.
[warning] server localhost:8529 shutdown
[  error] error running tests (please examine t/logs/error_log)
+--------------------------------------------------------+
| Please file a bug report: http://perl.apache.org/bugs/ |
+--------------------------------------------------------+
make: *** [run_tests] Error 1

$ vi t/logs/error_log

エラー出ました。
でもテストファイルの中みたらプロキシ関係のようだったので、dolipoあたりが邪魔したのかなーと思ってそのままいれた。

$ sudo make install
...
...
+--------------------------------------------------------------+
|                                                              |
| For details on getting started with mod_perl 2, see:         |
|                                                              |
|   http://perl.apache.org/docs/2.0/user/intro/start_fast.html |
|                                                              |
|                                                              |
| Found a bug?  File a bug report:                             |
|                                                              |
|   http://perl.apache.org/bugs/                               |
|                                                              |
+--------------------------------------------------------------+

httpd.confを編集してロードする。

$ sudo vi /etc/apache2/httpd.conf
...
LoadModule perl_module libexec/apache2/mod_perl.so
...

telnetでHTTPヘッダだけ見てみる。

$ telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.0

HTTP/1.1 200 OK
Date: Sun, 31 Jul 2011 02:38:26 GMT
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8r DAV/2 PHP/5.3.4 mod_perl/2.0.5 Perl/v5.14.1
Content-Location: index.html.en
Vary: negotiate
TCN: choice
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "14225-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Connection: close
Content-Type: text/html
Content-Language: en
...
...

大丈夫ぽい。


環境確認。

#!/usr/local/perl5/perlbrew/perls/perl-5.14.1/bin/perl
print "Content-type: text/plain\n\n";
foreach my $key (keys(%ENV)) {
  print "$key = $ENV{$key}\n";
}
MOD_PERL = mod_perl/2.0.5

が出てればオッケー。かな。