概要 †
ソースからインストールしたApacheにmod_perlをインストールします。
Apacheのインストールに関しては、以下のページを参照ください。
ソースから導入
手順 †
- ソースをダウンロードします。
1
2
3
| -
|
!
| wget http://perl.apache.org/dist/mod_perl-2.0-current.tar.gz
|
- 展開します。
1
|
| tar zxvf mod_perl-2.0.4
|
- 展開先へ移動します。
- makefileを作成します。
1
2
3
4
5
6
7
8
9
10
|
-
|
!
-
| perl Makefile.PL \
USE_APXS=1 \
WITH_APXS=<Apacheルート>/bin/apxs \
EVERYTHING=1 \
PERL_USELARGEFILES=0
Please provide a full path to 'apxs' executable
(press Enter if you don't have it installed): <Apacheルート>/bin/apxs
|
- ビルド、インストールします。
- <Apacheルート>/conf/httpd.confを開きます。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| -
!
-
|
!
-
!
| LoadModule perl_module modules/mod_perl.so
<IfModule mod_perl.c>
PerlRequire conf/startup.pl
<FilesMatch "\.(pl|cgi|pm)$">
SetHandler perl-script
PerlHandler ModPerl::Registry
PerlSendHeader On
Options +ExecCGI
</FilesMatch>
</IfModule>
|
- <Apacheルート>/conf/startup.plを作成します。
1
2
3
4
5
6
7
| -
!
| use APR::Const -compile => ':common';
use APR::Table ();
use ModPerl::Registry ();
use CGI -compile => ':all';
use CGI::Carp ();
1;
|
- Apacheを再起動します。
1
2
| -
!
| /etc/init.d/httpd restart
|
- 簡単なコードにて動作確認を行います。
以下のファイルを拡張子plで作成し、公開ディレクトリ内に置きます。
アクセスしたあとの更新によりカウントアップすればModPerl::Registryで動作しています。
1
2
3
|
| print "Content-Type: text/html\n\n";
$count++;
print "hello world [$count]";
|
- または、Apacheのログでも組み込まれていることを確認できます。
1
2
|
| tail <Apacheルート>/logs/error_log | grep mod_perl
[notice] Apache/2.2.12 (Unix) mod_perl/2.0.4 Perl/v5.8.8 configured -- resuming normal operations
|
検証時の環境 †
- CentOS 5.4 x86
- Apache 2.2.12
- mod_perl 2.0.4
参考 †