wata.dev

Mac OS X Snow Leopard で Apache2.2.15 に mod_perl2.04 を組み込む 1

そもそものきっかけは、Catalystでちょっとしたアプリを作ってみたので、付属のテストサーバーでなく、試したい!と思ったのがきっかけ。

で、Catalystの運用についていろいろ調べてみると、なんか「Apache + mod_perl最強!」とか言われている様子。早速「さくら mod_perl」で調べてみると、レンタルサーバーでは使えない、というか共用サーバーでは使えないみたいorz(まぁそりゃそうか)

Catalystをさくら(レンタルサーバー)で動かすだけなら方法はいくつかあるみたいなのですが、ここは今後のためにもmacのサイトフォルダ以下でmod_perlが使えるように試しておきたいと思います。

基本的には以下の流れ。

$ tar zxfv mod_perl-2.0-current.tar.gz
$ cd mod_perl-2.0.4
$ perl Makefile.PL USE_APXS=1 WITH_APXS=/usr/sbin/apxs EVERYTHING=1
$ make
$ su
Password: ********
# make install

これだけで十分な気も… ですが、一応記録。

0. mod_perlをダウンロード

最初にmod_perlをダウンロードしておく

$ wget http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz

1. perl Makefile.PL

まずはmod_perl-2.0-current.tar.gzを展開

$ tar zxfv mod_perl-2.0-current.tar.gz

で、

$ cd mod_perl-2.0.4
$ perl Makefile.PL USE_APXS=1 WITH_APXS=/usr/sbin/apxs EVERYTHING=1
Reading Makefile.PL args from @ARGV 
no conflicting prior mod_perl version found - good.

Next we need to know where the 'apxs' script is located. This script provides a lot of information about the Apache installation, and makes it easier to find things on your system. Normally it's located in the same directory as the 'httpd' executable.

If you don't yet have Apache installed you can build Apache against the Apache source code, but you won't be able to run the test suite (a very important step). Therefore you may want to install Apache before proceeding. 

Please provide a full path to 'apxs' executable
 (press Enter if you don't have it installed):  /usr/sbin/apxs

’apxs’がどこにあるかは、

$ which apxs
 /usr/sbin/apxs

で確認できる。あらかじめ確認しておくと良いかも。
パスを入力してEnterすると、

 [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.

のようなアラートが出て終了。

2. make、make install

ここまで来たらあとは、

$ make

   ・
   ・
   ・

$ su
Password: ********
# 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/                               |
 |                                                              |
 +--------------------------------------------------------------+

▼参考

ブログの記事一覧