Docker の CentOS7 に古いバージョンの Perl をインストールし、 Apache で使用する (5.16.3 → 5.8.9)

Docker の CentOS7 に古い Perl + Apache の環境を構築してみようと思います。

なお、参考までにバージョンは次のようになります。

  • httpd-devel 等インストール時のデフォルトの Perl: 5.16.3 (mod_cgi.so)
  • 指定してインストールする Perl: 5.8.9 (mod_perl.so)

準備

まずは CentOS7 イメージをダウンロード・ビルドします。

> docker run --name perl58_sample -it centos:centos7 /bin/bash

# 略

# 

まずここで Perl のバージョンを調べます。

# perl --version
bash: perl: command not found

まだ何もインストールされていないので、 Perl も存在しません。

Apache (httpd-devel) インストール

ここで httpd-devel をインストールします。

# yum -y update && yum -y install epel-release sudo less iproute httpd-devel zip unzip openssl mod_ssl

# 略

Installed:
  epel-release.noarch 0:7-11            httpd-devel.x86_64 0:2.4.6-97.el7.centos.2       iproute.x86_64 0:4.11.0-30.el7        
  less.x86_64 0:458-9.el7               mod_ssl.x86_64 1:2.4.6-97.el7.centos.2           openssl.x86_64 1:1.0.2k-22.el7_9      
  sudo.x86_64 0:1.8.23-10.el7_9.2       unzip.x86_64 0:6.0-22.el7_9                      zip.x86_64 0:3.0-11.el7

Dependency Installed:
  apr.x86_64 0:1.4.8-7.el7                                      apr-devel.x86_64 0:1.4.8-7.el7
  apr-util.x86_64 0:1.5.2-6.el7                                 apr-util-devel.x86_64 0:1.5.2-6.el7
  centos-logos.noarch 0:70.0.6-3.el7.centos                     cyrus-sasl.x86_64 0:2.1.26-23.el7
  cyrus-sasl-devel.x86_64 0:2.1.26-23.el7                       expat-devel.x86_64 0:2.1.0-12.el7
  groff-base.x86_64 0:1.22.2-8.el7                              httpd.x86_64 0:2.4.6-97.el7.centos.2
  httpd-tools.x86_64 0:2.4.6-97.el7.centos.2                    initscripts.x86_64 0:9.49.53-1.el7_9.1
  iptables.x86_64 0:1.4.21-35.el7                               libdb-devel.x86_64 0:5.3.21-25.el7
  libmnl.x86_64 0:1.0.3-7.el7                                   libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3
  libnfnetlink.x86_64 0:1.0.1-4.el7                             mailcap.noarch 0:2.1.41-2.el7
  make.x86_64 1:3.82-24.el7                                     openldap-devel.x86_64 0:2.4.44-24.el7_9
  perl.x86_64 4:5.16.3-299.el7_9                                perl-Carp.noarch 0:1.26-244.el7
  perl-Encode.x86_64 0:2.51-7.el7                               perl-Exporter.noarch 0:5.68-3.el7
  perl-File-Path.noarch 0:2.09-2.el7                            perl-File-Temp.noarch 0:0.23.01-3.el7
  perl-Filter.x86_64 0:1.49-3.el7                               perl-Getopt-Long.noarch 0:2.40-3.el7
  perl-HTTP-Tiny.noarch 0:0.033-3.el7                           perl-PathTools.x86_64 0:3.40-5.el7
  perl-Pod-Escapes.noarch 1:1.04-299.el7_9                      perl-Pod-Perldoc.noarch 0:3.20-4.el7
  perl-Pod-Simple.noarch 1:3.28-4.el7                           perl-Pod-Usage.noarch 0:1.63-3.el7
  perl-Scalar-List-Utils.x86_64 0:1.27-248.el7                  perl-Socket.x86_64 0:2.010-5.el7
  perl-Storable.x86_64 0:2.45-3.el7                             perl-Text-ParseWords.noarch 0:3.29-4.el7
  perl-Time-HiRes.x86_64 4:1.9725-3.el7                         perl-Time-Local.noarch 0:1.2300-2.el7
  perl-constant.noarch 0:1.27-2.el7                             perl-libs.x86_64 4:5.16.3-299.el7_9
  perl-macros.x86_64 4:5.16.3-299.el7_9                         perl-parent.noarch 1:0.225-244.el7
  perl-podlators.noarch 0:2.5.1-3.el7                           perl-threads.x86_64 0:1.87-4.el7
  perl-threads-shared.x86_64 0:1.43-6.el7                       sysvinit-tools.x86_64 0:2.88-14.dsf.el7

Complete!

# perl --version

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 44 registered patches, see perl -V for more detail)

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

インストール後に再び Perl のバージョンを確認すると、 5.16.3 と出ました。 Apache インストール時に同梱されたようです。

さて、本題はここから。デフォルトでは上述の通り 5.16.3 が入ってしまったので、これを 5.8系 まで下げたいと思います。

古い Perl のインストール (失敗)

# yum install -y wget make gcc

# 略

Installed:
  gcc.x86_64 0:4.8.5-44.el7
  wget.x86_64 0:1.14-18.el7_6.1

Dependency Installed:
  cpp.x86_64 0:4.8.5-44.el7                      glibc-devel.x86_64 0:2.17-325.el7_9   glibc-headers.x86_64 0:2.17-325.el7_9   
  kernel-headers.x86_64 0:3.10.0-1160.49.1.el7   libgomp.x86_64 0:4.8.5-44.el7         libmpc.x86_64 0:1.0.1-3.el7
  mpfr.x86_64 0:3.1.1-4.el7

Complete!

まずはダウンロード・ビルドに必要な wget, make, gcc をインストール。

# mkdir /var/perl58
# cd /var/perl58/

# wget http://www.cpan.org/src/perl-5.8.9.tar.gz
--yyyy-mm-dd hh:ii:ss--  http://www.cpan.org/src/perl-5.8.9.tar.gz
Resolving www.cpan.org (www.cpan.org)... 151.101.230.132, 2a04:4e42:36::644
Connecting to www.cpan.org (www.cpan.org)|151.101.230.132|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13954888 (13M) [application/x-gzip]
Saving to: 'perl-5.8.9.tar.gz'

100%[=====================================================================================>] 13,954,888  10.2MB/s   in 1.3s   

yyyy-mm-dd hh:ii:ss (10.2 MB/s) - 'perl-5.8.9.tar.gz' saved [13954888/13954888]

# tar zxvf perl-5.8.9.tar.gz

# 略

#

続いて古い Perl (5.8.9) をダウンロード・展開。

# cd perl-5.8.9

Configure

# ./Configure -des -Accflags='-fPIC' -Dprefix=/usr/local/perl-5.8.9 -Dscriptdir=/usr/local/perl-5.8.9/bin -DDEBUGGING=-g -Duseshrplib -Dman1dir=none -Dman3dir=none

# 略

make[1]: Entering directory `/var/perl58/perl-5.8.9'
echo Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH makedir.SH myconfig.SH writemain.SH pod/Makefile.SH | tr ' ' 
'\n' >.shlist
make[1]: Leaving directory `/var/perl58/perl-5.8.9'
Updating makefile...
test -s perlmain.c && touch perlmain.c
cd x2p; make depend
make[1]: Entering directory `/var/perl58/perl-5.8.9/x2p'
sh ../makedepend MAKE=make
make[2]: Entering directory `/var/perl58/perl-5.8.9/x2p'
echo hash.c  str.c util.c walk.c | tr ' ' '\n' >.clist
make[2]: Leaving directory `/var/perl58/perl-5.8.9/x2p'
Finding dependencies for hash.o.
Finding dependencies for str.o.
Finding dependencies for util.o.
Finding dependencies for walk.o.
make[2]: Entering directory `/var/perl58/perl-5.8.9/x2p'
echo Makefile.SH cflags.SH | tr ' ' '\n' >.shlist
make[2]: Leaving directory `/var/perl58/perl-5.8.9/x2p'
Updating makefile...
make[1]: Leaving directory `/var/perl58/perl-5.8.9/x2p'
Now you must run 'make'.

If you compile perl5 on a different machine or from a different object
directory, copy the Policy.sh file from this object directory to the
new one before you run Configure -- this will help you with most of
the policy defaults.

#

展開したディレクトリに移動して、 ./Configure でビルドの設定をします。

  • -des: -d, -e, -s の3つのオプションをまとめて指定。特に -d は「全ての設定値を Perl 推奨のデフォルトを使用」の意味で、 CLI の対話式の設定を省略するために指定
  • -Accflags='-fPIC': mod_perl での利用の場合、このオプションを付けないと mod_perlmake 時にエラーになるとのことなので付けておきます
  • -Dprefix=: インストールするディレクトリを指定するオプション。今回は /usr/local/perl-5.8.9 を指定した
  • -Dscriptdir=: Perl はいくつかのスクリプトを /usr/local/scirpt 等のようなグローバルなディレクトリにインストールしようとすることがある模様。これを抑止するためにスクリプトパスを明記。今回は /usr/local/perl-5.8.9/bin とした
  • -DDEBUGGING=-g: デバッグ有効
  • -Duseshrplib: Perl と動的リンクさせて動くソフトのためのオプション。今回 mod_perl がこれに該当するためオプション指定
  • -Dman1dir=none, -Dman3dir=none: man 形式のドキュメントの作成・インストールを省くためのオプション

後で気付いたのですが、実はこのときもう一つオプション (-Duseithreads) の指定が必要で、ここからやり直す羽目になりました。

make test

# make test

# 略

Failed 3 tests out of 1104, 99.73% okay.
        ../lib/Time/Local.t
        comp/cpp.t
        run/switchPx.t
### Since not all tests were successful, you may want to run some of
### them individually and examine any diagnostic messages they produce.
### See the INSTALL document's section on "make test".
### You have a good chance to get more information by running
###   ./perl harness
### in the 't' directory since most (>=80%) of the tests succeeded.
### You may have to set your dynamic library search path,
### LD_LIBRARY_PATH, to point to the build directory:
###   setenv LD_LIBRARY_PATH `pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
###   LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd t; ./perl harness
###   export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### for csh-style shells, like tcsh; or for traditional/modern
### Bourne-style shells, like bash, ksh, and zsh, respectively.
u=2.09  s=2.02  cu=96.91  cs=15.45  scripts=1104  tests=133461
make[2]: *** [_test_tty] Error 1
make[2]: Leaving directory `/var/perl58/perl-5.8.9'
make[1]: *** [_test] Error 2
make[1]: Leaving directory `/var/perl58/perl-5.8.9'
make: *** [test] Error 2

エラーが2つ出ていますが気にしない。

make install

# make install

# 略

Warning: perl appears in your path in the following locations beyond where
we just installed it:
    /usr/bin/perl
    /bin/perl

LD_LIBRARY_PATH=/var/perl58/perl-5.8.9  ./perl installman --destdir= 
Skipping installation of pod man pages.
Skipping installation of lib man pages.
Skipping installation of pod/pod2html man page.
Skipping installation of pod/pod2latex man page.
Skipping installation of pod/pod2man man page.
Skipping installation of pod/pod2text man page.
Skipping installation of pod/pod2usage man page.
Skipping installation of pod/podchecker man page.
Skipping installation of pod/podselect man page.
Skipping installation of utils/c2ph man page.
Skipping installation of utils/cpan man page.
Skipping installation of utils/corelist man page.
Skipping installation of utils/dprofpp man page.
Skipping installation of utils/enc2xs man page.
Skipping installation of utils/h2ph man page.
Skipping installation of utils/h2xs man page.
Skipping installation of utils/instmodsh man page.
Skipping installation of utils/libnetcfg man page.
Skipping installation of utils/perlbug man page.
Skipping installation of utils/perlcc man page.
Skipping installation of pod/perldoc.pod man page.
Skipping installation of utils/perlivp man page.
Skipping installation of utils/piconv man page.
Skipping installation of utils/pl2pm man page.
Skipping installation of utils/prove man page.
Skipping installation of utils/splain man page.
Skipping installation of utils/xsubpp man page.
Skipping installation of x2p/a2p.pod man page.
Skipping installation of x2p/find2perl man page.
Skipping installation of x2p/s2p man page.
make[1]: Leaving directory `/var/perl58/perl-5.8.9'

#

OK。

確認

# /usr/local/perl-5.8.9/bin/perl -v

This is perl, v5.8.9 built for x86_64-linux

Copyright 1987-2008, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

バージョン情報が表示されるのでOKです。

# ls -al /usr/bin/perl
-rwxr-xr-x 2 root root 11408 Feb  2  2021 /usr/bin/perl
# /usr/local/perl-5.8.9/bin/perl -V | grep ithread
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef

他にいくつか情報表示。

# perl --version

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 44 registered patches, see perl -V for more detail)

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

ただし、まだリンクは httpd-devel インストール時に入った Perl を指しているので普通の perl コマンドでは 5.16.3 の方が反応します。

シンボリックリンク貼り替え

# ln -s /usr/local/perl-5.8.9/bin/perl /usr/local/bin/perl
#

OK。

# perl --version

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 44 registered patches, see perl -V for more detail)

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

ただし、 bash から抜けてセッションを切るか再起動するかしないと表示は切り替わらなさそうですね。

そこで、いったん bash から抜けて、ついでにイメージを作成します。

> docker commit XXXXXXXXXXXX perl58-sample:0.0.1
sha256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

> docker stop perl58_sample
perl58_sample

OK。いったんコンテナを停止させて破棄します。

> docker run -d -p 8080:80 --name perl58_sample -it perl58-sample:0.0.1 /bin/bash
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

> docker container exec -it perl58_sample /bin/bash

先程作成したイメージからコンテナをビルドして、 bash に入ります。

# perl --version

This is perl, v5.8.9 built for x86_64-linux

Copyright 1987-2008, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

OK。 perl コマンドでも 5.8.9 が表示されるようになりました。

Webサーバ準備 (失敗)

続いてWebサーバの準備

仮想ホストの conf (http)

# vi /etc/httpd/conf.d/sample.conf

<VirtualHost *:80>
    DocumentRoot "/var/www/samplesite/web"
    ServerName www.lvh.me
    ServerAlias lvh.me
    ScriptAlias /cgi-bin/ /var/www/samplesite/web/cgi-bin/
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^lvh.me$
    RewriteRule ^(.*)$       http://www.lvh.me/$1 [R=301,L]
    <Directory "/var/www/samplesite/web">
        allow from all
        AllowOverride All
        Options +ExecCGI
        Require all granted
        AddHandler cgi-script .cgi .pl
        DirectoryIndex index.html index.cgi
    </Directory>
</VirtualHost>

仮想ホストの conf (https)

# vi /etc/httpd/conf.d/sample_ssl.conf

<IfModule mod_ssl.c>
    <VirtualHost *:443>
        DocumentRoot "/var/www/samplesite/web"
        ServerName www.lvh.me
        ServerAlias lvh.me
        ScriptAlias /cgi-bin/ /var/www/samplesite/web/cgi-bin/
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^lvh.me$
        RewriteRule ^(.*)$       https://www.lvh.me/$1 [R=301,L]
        <Directory "/var/www/samplesite/web">
            allow from all
            AllowOverride All
            Options +ExecCGI
            Require all granted
            AddHandler cgi-script .cgi .pl
            DirectoryIndex index.html index.cgi
        </Directory>
        SSLEngine on
        SSLCertificateFile /etc/ssl/private/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
    </VirtualHost>
</IfModule>

ssl.conf

# mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak
# vi /etc/httpd/conf.d/ssl.conf

# SSLProtocol all -SSLv2 -SSLv3
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1

SSLはTLS1.1まで無効にします。

ディレクトリ

# mkdir /var/www/samplesite
# mkdir /var/www/samplesite/web
# mkdir /var/www/samplesite/web/cgi-bin

サンプルスクリプト

# vi /var/www/samplesite/web/cgi-bin/index.cgi

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print $];
exit;

# ls -al /var/www/samplesite/web/cgi-bin/index.cgi 
-rw-r--r-- 1 root root 70 MMM dd hh:ii /var/www/samplesite/web/cgi-bin/index.cgi
# chmod 755 /var/www/samplesite/web/cgi-bin/index.cgi 

SSL証明書(オレオレ証明書)

# mkdir -p /etc/ssl/private
# openssl req -new -newkey rsa:2048 -nodes -out /etc/ssl/private/server.csr -keyout /etc/ssl/private/server.key -subj "/C=/ST=/L=/O=/OU=/CN=*.lvh.me"

# 略

# openssl x509 -days 365 -req -signkey /etc/ssl/private/server.key -in /etc/ssl/private/server.csr -out /etc/ssl/private/server.crt
Signature ok
subject=/CN=*.lvh.me
Getting Private key

OK。

再度コミットして http, https 両方で待ち受けるように

# exit
exit
> docker ps                                                                           
CONTAINER ID   IMAGE                 COMMAND       CREATED          STATUS          PORTS                  NAMES
XXXXXXXXXXXX   perl58-sample:0.0.1   "/bin/bash"   34 minutes ago   Up 34 minutes   0.0.0.0:8080->80/tcp   perl58_sample       
> docker commit XXXXXXXXXXXX perl58-sample:0.0.2                                      
sha256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

OK。

> docker run -d -p 8080:80 -p 4043:443 --name perl58_sample -it perl58-sample:0.0.2 /bin/bash
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
> docker container exec -it perl58_sample /bin/bash
# /usr/sbin/httpd -DFOREGROUND &
[1] 38
#

これでOK、と思ったのですが……。

未だに 5.16.3 と出る
未だに 5.16.3 と出る

5.16.3 のままでした。あれ……?

ここで再度調べてみると、 mod_perl を入れ替えないとだめらしいので作業継続です。

うーん、ぬか喜び。

mod_perl インストール (失敗)

ということで、よもやよもやの第二部です。

ダウンロード・展開

# cd /var/perl58/
# wget https://dlcdn.apache.org/perl/mod_perl-2.0.11.tar.gz
--yyyy-mm-dd hh:ii:ss--  https://dlcdn.apache.org/perl/mod_perl-2.0.11.tar.gz
Resolving dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
Connecting to dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3848147 (3.7M) [application/x-gzip]
Saving to: ‘mod_perl-2.0.11.tar.gz’

100%[=====================================================================================>] 3,848,147   15.2MB/s   in 0.2s   

yyyy-mm-dd hh:ii:ss (15.2 MB/s) - ‘mod_perl-2.0.11.tar.gz’ saved [3848147/3848147]

# tar zxvf mod_perl-2.0.11.tar.gz

# 略

#

ダウンロード・展開します。

ちなみに軽いトラップ気味な現象として、 mod_perl: Download から「Download」のリンク先(https://www.apache.org/dyn/closer.cgi/perl/mod_perl-2.0.11.tar.gz)を指定したのですが、このリンク先、 tar.gz となっているものの普通にWebページとして閲覧できます。

実際のダウンロードリンクは https://dlcdn.apache.org/perl/mod_perl-2.0.11.tar.gz となっており、URL文字列で早合点すると展開時に「tar.gz 形式ではありません」という旨で怒られ続け、ダウンロードに失敗したものと思い込んで嵌まる可能性があります (嵌まった)。

Makefile.PL

# /usr/sbin/httpd -l
Compiled in modules:
  core.c
  mod_so.c
  http_core.c

# find / -name "*apxs*"
/var/perl58/mod_perl-2.0.11/build/win32_fetch_apxs
/usr/bin/apxs

Apache が読み込んでいるモジュールの一覧と、 Apache の拡張モジュールをビルド・インストールする APXS を利用するためにパスを確認します。

# cd mod_perl-2.0.11

# perl Makefile.PL MP_APXS=/usr/bin/apxs
Reading Makefile.PL args from @ARGV
   MP_APXS = /usr/bin/apxs
no conflicting prior mod_perl version found - good.
Using APXS => /usr/bin/apxs
Configuring Apache/2.4.6 mod_perl/2.0.11 Perl/v5.8.9
[  error] Using Perl 5.8.9 w/o ithreads and httpd-2.4.
[  error] Failed requirements:
[  error]   - Perl built with ithreads (build perl with -Duseithreads)

oh… ここに来て、冒頭の Perl を make するときの Configure で -Duseithreads オプションを指定し忘れたことに気付きました。

ということで、ほぼ振り出しに戻り Perl の make からやり直しです。

古い Perl のインストール

# cd ../perl-5.8.9

# make clean

# 略

==> Your Makefile has been rebuilt. <==
==> Please rerun the make command.  <==
false
make[1]: *** [Makefile] Error 1
make[1]: Leaving directory `/var/perl58/perl-5.8.9/ext/Module/Pluggable'
make: [_tidy] Error 2 (ignored)
rm -f testcompile compilelog
rm -f *.o *.a all perlmain.c opmini.c
rmdir .depending
rmdir: failed to remove ‘.depending’: No such file or directory
make: [_mopup] Error 1 (ignored)
make: [_mopup] Error 1 (ignored)
rm -f perl.exp ext.libs extra.pods uni.data opmini.o
rm -f perl.export perl.dll perl.libexp perl.map perl.def
rm -f perl.loadmap miniperl.loadmap perl.prelmap miniperl.prelmap
rm -f perl.third lib*.so.perl.third perl.3log t/perl.third t/perl.3log
rm -f perl.pixie lib*.so.perl.pixie lib*.so.Addrs
rm -f perl.Addrs perl.Counts t/perl.Addrs t/perl.Counts *perl.xok
rm -f cygwin.c libperl*.def libperl*.dll cygperl*.dll *.exe.stackdump
rm -f perl suidperl miniperl libperl.so libperl.* microperl
rm -f opcode.h-old opnames.h-old pp.sym-old pp_proto.h-old
rm -f config.arch config.over

まずは make clean で綺麗にして。

./Configure

# ./Configure -des -Accflags='-fPIC' -Dprefix=/usr/local/perl-5.8.9 -Dscriptdir=/usr/local/perl-5.8.9/bin -DDEBUGGING=-g -Duseshrplib -Dman1dir=none -Dman3dir=none -Duseithreads

# 略

make[1]: Entering directory `/var/perl58/perl-5.8.9'
echo Makefile.SH cflags.SH config_h.SH makeaperl.SH makedepend.SH makedir.SH myconfig.SH writemain.SH pod/Makefile.SH | tr ' ' 
'\n' >.shlist
make[1]: Leaving directory `/var/perl58/perl-5.8.9'
Updating makefile...
test -s perlmain.c && touch perlmain.c
cd x2p; make depend
make[1]: Entering directory `/var/perl58/perl-5.8.9/x2p'
sh ../makedepend MAKE=make
make[2]: Entering directory `/var/perl58/perl-5.8.9/x2p'
echo hash.c  str.c util.c walk.c | tr ' ' '\n' >.clist
make[2]: Leaving directory `/var/perl58/perl-5.8.9/x2p'
Finding dependencies for hash.o.
Finding dependencies for str.o.
Finding dependencies for util.o.
Finding dependencies for walk.o.
make[2]: Entering directory `/var/perl58/perl-5.8.9/x2p'
echo Makefile.SH cflags.SH | tr ' ' '\n' >.shlist
make[2]: Leaving directory `/var/perl58/perl-5.8.9/x2p'
Updating makefile...
make[1]: Leaving directory `/var/perl58/perl-5.8.9/x2p'
Now you must run 'make'.

If you compile perl5 on a different machine or from a different object
directory, copy the Policy.sh file from this object directory to the
new one before you run Configure -- this will help you with most of
the policy defaults.

再び ./Configure 。今度は -Duseithreads を付けます。

  • -des: -d, -e, -s の3つのオプションをまとめて指定。特に -d は「全ての設定値を Perl 推奨のデフォルトを使用」の意味で、 CLI の対話式の設定を省略するために指定
  • -Accflags='-fPIC': mod_perl での利用の場合、このオプションを付けないと mod_perlmake 時にエラーになるとのことなので付けておきます
  • -Dprefix=: インストールするディレクトリを指定するオプション。今回は /usr/local/perl-5.8.9 を指定した
  • -Dscriptdir=: Perl はいくつかのスクリプトを /usr/local/scirpt 等のようなグローバルなディレクトリにインストールしようとすることがある模様。これを抑止するためにスクリプトパスを明記。今回は /usr/local/perl-5.8.9/bin とした
  • -DDEBUGGING=-g: デバッグ有効
  • -Duseshrplib: Perl と動的リンクさせて動くソフトのためのオプション。今回 mod_perl がこれに該当するためオプション指定
  • -Dman1dir=none, -Dman3dir=none: man 形式のドキュメントの作成・インストールを省くためのオプション
  • -Duseithreads: Perl のスレッド機能を有効にするオプション

make test

# make test

# 略

Failed 3 tests out of 1152, 99.74% okay.
        ../lib/Time/Local.t
        comp/cpp.t
        run/switchPx.t
### Since not all tests were successful, you may want to run some of
### them individually and examine any diagnostic messages they produce.
### See the INSTALL document's section on "make test".
### You have a good chance to get more information by running
###   ./perl harness
### in the 't' directory since most (>=80%) of the tests succeeded.
### You may have to set your dynamic library search path,
### LD_LIBRARY_PATH, to point to the build directory:
###   setenv LD_LIBRARY_PATH `pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
###   LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd t; ./perl harness
###   export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### for csh-style shells, like tcsh; or for traditional/modern
### Bourne-style shells, like bash, ksh, and zsh, respectively.
u=2.17  s=2.06  cu=114.19  cs=20.63  scripts=1152  tests=134801
make[2]: *** [_test_tty] Error 1
make[2]: Leaving directory `/var/perl58/perl-5.8.9'
make[1]: *** [_test] Error 2
make[1]: Leaving directory `/var/perl58/perl-5.8.9'
make: *** [test] Error 2

make install

# make install

# 略

Warning: perl appears in your path in the following locations beyond where
we just installed it:
    /usr/local/bin/perl
    /usr/bin/perl
    /bin/perl

LD_LIBRARY_PATH=/var/perl58/perl-5.8.9  ./perl installman --destdir= 
Skipping installation of pod man pages.
Skipping installation of lib man pages.
Skipping installation of pod/pod2html man page.
Skipping installation of pod/pod2latex man page.
Skipping installation of pod/pod2man man page.
Skipping installation of pod/pod2text man page.
Skipping installation of pod/pod2usage man page.
Skipping installation of pod/podchecker man page.
Skipping installation of pod/podselect man page.
Skipping installation of utils/c2ph man page.
Skipping installation of utils/cpan man page.
Skipping installation of utils/corelist man page.
Skipping installation of utils/dprofpp man page.
Skipping installation of utils/enc2xs man page.
Skipping installation of utils/h2ph man page.
Skipping installation of utils/h2xs man page.
Skipping installation of utils/instmodsh man page.
Skipping installation of utils/libnetcfg man page.
Skipping installation of utils/perlbug man page.
Skipping installation of utils/perlcc man page.
Skipping installation of pod/perldoc.pod man page.
Skipping installation of utils/perlivp man page.
Skipping installation of utils/piconv man page.
Skipping installation of utils/pl2pm man page.
Skipping installation of utils/prove man page.
Skipping installation of utils/splain man page.
Skipping installation of utils/xsubpp man page.
Skipping installation of x2p/a2p.pod man page.
Skipping installation of x2p/find2perl man page.
Skipping installation of x2p/s2p man page.
make[1]: Leaving directory `/var/perl58/perl-5.8.9'

OK。

mod_perl のインストール

これで mod_perl に戻ります。

# cd ../mod_perl-2.0.11

Makefile.PL

# perl Makefile.PL MP_APXS=/usr/bin/apxs MP_AP_CONFIGURE="prefix=/usr/local/mod_perl-2.0.11 -enable-so -enable-rewrite"
Reading Makefile.PL args from @ARGV
   MP_APXS = /usr/bin/apxs
   MP_AP_CONFIGURE = prefix=/usr/local/mod_perl-2.0.11 -enable-so -enable-rewrite
no conflicting prior mod_perl version found - good.
Using APXS => /usr/bin/apxs
Configuring Apache/2.4.6 mod_perl/2.0.11 Perl/v5.8.9
Writing Makefile for Apache2::Reload
Writing Makefile for Apache2::SizeLimit
Subroutine set_version redefined at ./Makefile.PL line 131.
[   info] generating script t/TEST
[   info] generating script ./t/cgi-bin/cookies.pl
[   info] generating script ./t/cgi-bin/next_available_port.pl
Writing Makefile for Apache::Test
Checking for Cwd...ok
Checking for File::Spec...ok

# 略

[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/bin/apxs -q LIBEXECDIR
[warning]
[warning] and adjust the LoadModule directive accordingly.

#

OK。

make

# make

# 略

chmod 755 ../../../blib/arch/auto/APR/Const/Const.so
cp Const.bs ../../../blib/arch/auto/APR/Const/Const.bs
chmod 644 ../../../blib/arch/auto/APR/Const/Const.bs
make[3]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs/APR/Const'
make[3]: Entering directory `/var/perl58/mod_perl-2.0.11/xs/APR/PerlIO'
cp PerlIO.pm ../../../blib/lib/APR/PerlIO.pm
/usr/local/perl-5.8.9/bin/perl /usr/local/perl-5.8.9/lib/5.8.9/ExtUtils/xsubpp  -typemap /usr/local/perl-5.8.9/lib/5.8.9/ExtUtils/typemap -typemap /var/perl58/mod_perl-2.0.11/xs/typemap  PerlIO.xs > PerlIO.xsc && mv PerlIO.xsc PerlIO.c
cc -c  -I/var/perl58/mod_perl-2.0.11/src/modules/perl -I/var/perl58/mod_perl-2.0.11/xs -I/usr/include/apr-1 -I/usr/include/apr-1  -I/usr/include/httpd -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fPIC -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -I/usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/CORE -DMOD_PERL -DMP_COMPAT_1X -DLINUX -DMP_IN_XS -O2 -g   -DVERSION=\"0.009000\" -DXS_VERSION=\"0.009000\" -fPIC "-I/usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/CORE"  -DMP_HAVE_APR_LIBS PerlIO.c
cc -c  -I/var/perl58/mod_perl-2.0.11/src/modules/perl -I/var/perl58/mod_perl-2.0.11/xs -I/usr/include/apr-1 -I/usr/include/apr-1  -I/usr/include/httpd -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fPIC -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -I/usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/CORE -DMOD_PERL -DMP_COMPAT_1X -DLINUX -DMP_IN_XS -O2 -g   -DVERSION=\"0.009000\" -DXS_VERSION=\"0.009000\" -fPIC "-I/usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/CORE"  -DMP_HAVE_APR_LIBS modperl_apr_perlio.c
Running Mkbootstrap for APR::PerlIO ()
chmod 644 PerlIO.bs
rm -f ../../../blib/arch/auto/APR/PerlIO/PerlIO.so
cc  -shared -O2 -g -L/usr/local/lib PerlIO.o modperl_apr_perlio.o -L/usr/local/lib -o ../../../blib/arch/auto/APR/PerlIO/PerlIO.so     \
        \

chmod 755 ../../../blib/arch/auto/APR/PerlIO/PerlIO.so
cp PerlIO.bs ../../../blib/arch/auto/APR/PerlIO/PerlIO.bs
chmod 644 ../../../blib/arch/auto/APR/PerlIO/PerlIO.bs
make[3]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs/APR/PerlIO'
make[3]: Entering directory `/var/perl58/mod_perl-2.0.11/xs/APR/aprext'
make[3]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs/APR/aprext'
make[2]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs/APR'
make[2]: Entering directory `/var/perl58/mod_perl-2.0.11/xs/Apache2'
make[3]: Entering directory `/var/perl58/mod_perl-2.0.11/xs/Apache2/Const'
cp Const.pm ../../../blib/lib/Apache2/Const.pm
/usr/local/perl-5.8.9/bin/perl /usr/local/perl-5.8.9/lib/5.8.9/ExtUtils/xsubpp  -typemap /usr/local/perl-5.8.9/lib/5.8.9/ExtUtils/typemap -typemap /var/perl58/mod_perl-2.0.11/xs/typemap  Const.xs > Const.xsc && mv Const.xsc Const.c
cc -c  -I/var/perl58/mod_perl-2.0.11/src/modules/perl -I/var/perl58/mod_perl-2.0.11/xs -I/usr/include/apr-1 -I/usr/include/apr-1  -I/usr/include/httpd -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fPIC -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DMOD_PERL -DMP_COMPAT_1X -DLINUX -D_REENTRANT -D_GNU_SOURCE  -O2 -g   -DVERSION=\"2.000011\" -DXS_VERSION=\"2.000011\" -fPIC "-I/usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/CORE"  -DMP_HAVE_APR_LIBS Const.c
Running Mkbootstrap for Apache2::Const ()
chmod 644 Const.bs
rm -f ../../../blib/arch/auto/Apache2/Const/Const.so
cc  -shared -O2 -g -L/usr/local/lib Const.o -L/usr/local/lib -o ../../../blib/arch/auto/Apache2/Const/Const.so  \
        \

chmod 755 ../../../blib/arch/auto/Apache2/Const/Const.so
cp Const.bs ../../../blib/arch/auto/Apache2/Const/Const.bs
chmod 644 ../../../blib/arch/auto/Apache2/Const/Const.bs
make[3]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs/Apache2/Const'
make[2]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs/Apache2'
make[2]: Entering directory `/var/perl58/mod_perl-2.0.11/xs/ModPerl'
make[3]: Entering directory `/var/perl58/mod_perl-2.0.11/xs/ModPerl/Const'
cp Const.pm ../../../blib/lib/ModPerl/Const.pm
/usr/local/perl-5.8.9/bin/perl /usr/local/perl-5.8.9/lib/5.8.9/ExtUtils/xsubpp  -typemap /usr/local/perl-5.8.9/lib/5.8.9/ExtUtils/typemap -typemap /var/perl58/mod_perl-2.0.11/xs/typemap  Const.xs > Const.xsc && mv Const.xsc Const.c
cc -c  -I/var/perl58/mod_perl-2.0.11/src/modules/perl -I/var/perl58/mod_perl-2.0.11/xs -I/usr/include/apr-1 -I/usr/include/apr-1  -I/usr/include/httpd -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fPIC -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DMOD_PERL -DMP_COMPAT_1X -DLINUX -D_REENTRANT -D_GNU_SOURCE  -O2 -g   -DVERSION=\"2.000011\" -DXS_VERSION=\"2.000011\" -fPIC "-I/usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/CORE"  -DMP_HAVE_APR_LIBS Const.c
cp ../../../src/modules/perl/modperl_const.c .
cc -c  -I/var/perl58/mod_perl-2.0.11/src/modules/perl -I/var/perl58/mod_perl-2.0.11/xs -I/usr/include/apr-1 -I/usr/include/apr-1  -I/usr/include/httpd -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fPIC -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DMOD_PERL -DMP_COMPAT_1X -DLINUX -D_REENTRANT -D_GNU_SOURCE  -O2 -g   -DVERSION=\"2.000011\" -DXS_VERSION=\"2.000011\" -fPIC "-I/usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/CORE"  -DMP_HAVE_APR_LIBS modperl_const.c
cp ../../../src/modules/perl/modperl_constants.c .
cc -c  -I/var/perl58/mod_perl-2.0.11/src/modules/perl -I/var/perl58/mod_perl-2.0.11/xs -I/usr/include/apr-1 -I/usr/include/apr-1  -I/usr/include/httpd -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fPIC -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DMOD_PERL -DMP_COMPAT_1X -DLINUX -D_REENTRANT -D_GNU_SOURCE  -O2 -g   -DVERSION=\"2.000011\" -DXS_VERSION=\"2.000011\" -fPIC "-I/usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/CORE"  -DMP_HAVE_APR_LIBS modperl_constants.c
Running Mkbootstrap for ModPerl::Const ()
chmod 644 Const.bs
rm -f ../../../blib/arch/auto/ModPerl/Const/Const.so
cc  -shared -O2 -g -L/usr/local/lib Const.o modperl_const.o modperl_constants.o -L/usr/local/lib -o ../../../blib/arch/auto/ModPerl/Const/Const.so     \
        \

chmod 755 ../../../blib/arch/auto/ModPerl/Const/Const.so
cp Const.bs ../../../blib/arch/auto/ModPerl/Const/Const.bs
chmod 644 ../../../blib/arch/auto/ModPerl/Const/Const.bs
make[3]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs/ModPerl/Const'
make[2]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs/ModPerl'
make[1]: Leaving directory `/var/perl58/mod_perl-2.0.11/xs'
cp bin/mp2bug blib/script/mp2bug
/usr/local/perl-5.8.9/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/mp2bug

OK。

make install

# make install

# 略

Installing none/Apache2::ServerRec.0
Installing none/APR::IpSubnet.0
Installing none/APR::PerlIO.0
Installing none/APR::SockAddr.0
Installing none/APR::UUID.0
Installing none/Apache2::Log.0
Installing none/Apache2::porting.0
Installing none/Apache2::Const.0
Installing none/Apache2::ConnectionUtil.0
Installing none/Apache2::Filter.0
Installing none/APR::Finfo.0
Installing none/ModPerl::MethodLookup.0
Installing none/APR::Util.0
Installing none/Apache2::Module.0
Installing none/Apache2::Response.0
Installing none/Apache2::CmdParms.0
Installing none/Apache2::HookRun.0
Installing none/Apache2::compat.0
Installing none/ModPerl::MM.0
Installing none/Apache2::Util.0
Installing none/APR::Status.0
Installing none/ModPerl::PerlRun.0
Installing none/Apache2::RequestRec.0
Installing none/APR::Brigade.0
Installing none/Apache2::SubRequest.0
Installing none/Apache2::Process.0
Installing none/ModPerl::Registry.0
Installing none/ModPerl::PerlRunPrefork.0
Installing none/APR::BucketAlloc.0
Installing none/Apache2::Status.0
Installing none/APR::BucketType.0
Installing none/Apache2::Access.0
Installing none/Apache2::RequestIO.0
Installing none/Apache2::Connection.0
Installing none/APR::Base64.0
Installing none/APR::Table.0
Installing none/APR.0
Installing none/APR::ThreadMutex.0
Installing none/Apache2::FilterRec.0
Installing none/APR::Socket.0
Installing none/APR::Date.0
Installing none/ModPerl::BuildMM.0
Installing none/APR::String.0
Installing none/Apache2::Directive.0
Installing none/ModPerl::RegistryLoader.0
Installing none/Apache2::Resource.0
Installing none/ModPerl::Util.0
Installing none/Apache2::URI.0
Installing none/APR::Bucket.0
Installing none/Apache2::MPM.0
Installing none/APR::ThreadRWLock.0
Installing none/APR::URI.0
Installing none/Apache2::Command.0
Installing none/Apache2::PerlSections.0
Installing none/ModPerl::RegistryPrefork.0
Installing none/ModPerl::RegistryBB.0
Installing none/APR::OS.0
Installing none/ModPerl::Global.0
Installing none/Apache2::SubProcess.0
Installing none/Apache2::ServerUtil.0
Installing none/APR::Error.0
Installing none/APR::Const.0
Installing none/ModPerl::Const.0
Installing none/APR::Pool.0
Installing none/Apache2::RequestUtil.0
Installing none/ModPerl::RegistryCooker.0
Installing /usr/local/perl-5.8.9/bin/mp2bug
Writing /usr/local/perl-5.8.9/lib/site_perl/5.8.9/x86_64-linux-thread-multi/auto/mod_perl2/.packlist
Appending installation info to /usr/local/perl-5.8.9/lib/5.8.9/x86_64-linux-thread-multi/perllocal.pod
+--------------------------------------------------------------+
|                                                              |
| 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/                               |
|                                                              |
+--------------------------------------------------------------+

OK。

Apache に mod_perl を読み込ませる

ビルドが完了したので Apache に mod_perl を読み込ませます。

# find / -name "*mod_perl*"
/var/perl58/mod_perl-2.0.11
/var/perl58/mod_perl-2.0.11/src/modules/perl/mod_perl.h
/var/perl58/mod_perl-2.0.11/src/modules/perl/mod_perl.c
/var/perl58/mod_perl-2.0.11/src/modules/perl/mod_perl.so
/var/perl58/mod_perl-2.0.11/src/modules/perl/mod_perl.lo
/var/perl58/mod_perl-2.0.11/mod_perl.spec
/var/perl58/mod_perl-2.0.11/docs/devel/core/mod_perl_specific.pod
/var/perl58/mod_perl-2.0.11/docs/user/handlers/practical_mod_perl_comp.gif
/var/perl58/mod_perl-2.0.11/lib/mod_perl2.pm
/var/perl58/mod_perl-2.0.11/blib/arch/auto/mod_perl2
/var/perl58/mod_perl-2.0.11/blib/lib/auto/mod_perl2
/var/perl58/mod_perl-2.0.11/blib/lib/mod_perl2.pm
/var/perl58/mod_perl-2.0.11.tar.gz
/usr/local/perl-5.8.9/lib/site_perl/5.8.9/x86_64-linux-thread-multi/auto/mod_perl2
/usr/local/perl-5.8.9/lib/site_perl/5.8.9/x86_64-linux-thread-multi/mod_perl2.pm
/usr/lib64/httpd/modules/mod_perl.so
/usr/include/httpd/mod_perl.h

# ls -al /usr/lib64/httpd/modules/
total 4396
drwxr-xr-x 1 root root    4096 MMM dd hh:ii .
drwxr-xr-x 1 root root    4096 MMM dd hh:ii ..
-rwxr-xr-x 1 root root   11232 Nov 10 14:27 mod_access_compat.so
-rwxr-xr-x 1 root root   11176 Nov 10 14:27 mod_actions.so
-rwxr-xr-x 1 root root   15376 Nov 10 14:27 mod_alias.so
-rwxr-xr-x 1 root root   11152 Nov 10 14:27 mod_allowmethods.so
-rwxr-xr-x 1 root root   11104 Nov 10 14:27 mod_asis.so
-rwxr-xr-x 1 root root   15336 Nov 10 14:27 mod_auth_basic.so
-rwxr-xr-x 1 root root   36088 Nov 10 14:27 mod_auth_digest.so
-rwxr-xr-x 1 root root   11160 Nov 10 14:27 mod_authn_anon.so
-rwxr-xr-x 1 root root   15376 Nov 10 14:27 mod_authn_core.so
-rwxr-xr-x 1 root root   15280 Nov 10 14:27 mod_authn_dbd.so
-rwxr-xr-x 1 root root   11200 Nov 10 14:27 mod_authn_dbm.so
-rwxr-xr-x 1 root root   11176 Nov 10 14:27 mod_authn_file.so
-rwxr-xr-x 1 root root   19552 Nov 10 14:27 mod_authn_socache.so
-rwxr-xr-x 1 root root   23752 Nov 10 14:27 mod_authz_core.so
-rwxr-xr-x 1 root root   15304 Nov 10 14:27 mod_authz_dbd.so
-rwxr-xr-x 1 root root   11216 Nov 10 14:27 mod_authz_dbm.so
-rwxr-xr-x 1 root root   11200 Nov 10 14:27 mod_authz_groupfile.so
-rwxr-xr-x 1 root root   11192 Nov 10 14:27 mod_authz_host.so
-rwxr-xr-x 1 root root   11144 Nov 10 14:27 mod_authz_owner.so
-rwxr-xr-x 1 root root    7040 Nov 10 14:27 mod_authz_user.so
-rwxr-xr-x 1 root root   40080 Nov 10 14:27 mod_autoindex.so
-rwxr-xr-x 1 root root   11168 Nov 10 14:27 mod_buffer.so
-rwxr-xr-x 1 root root   36104 Nov 10 14:27 mod_cache_disk.so
-rwxr-xr-x 1 root root   73280 Nov 10 14:27 mod_cache.so
-rwxr-xr-x 1 root root   36072 Nov 10 14:27 mod_cache_socache.so
-rwxr-xr-x 1 root root   36104 Nov 10 14:27 mod_cgid.so
-rwxr-xr-x 1 root root   27720 Nov 10 14:27 mod_cgi.so
-rwxr-xr-x 1 root root   23600 Nov 10 14:27 mod_charset_lite.so
-rwxr-xr-x 1 root root   11096 Nov 10 14:27 mod_data.so
-rwxr-xr-x 1 root root   57120 Nov 10 14:27 mod_dav_fs.so
-rwxr-xr-x 1 root root   19648 Nov 10 14:27 mod_dav_lock.so
-rwxr-xr-x 1 root root  102440 Nov 10 14:27 mod_dav.so
-rwxr-xr-x 1 root root   23632 Nov 10 14:27 mod_dbd.so
-rwxr-xr-x 1 root root   31840 Nov 10 14:27 mod_deflate.so
-rwxr-xr-x 1 root root   11184 Nov 10 14:27 mod_dialup.so
-rwxr-xr-x 1 root root   15288 Nov 10 14:27 mod_dir.so
-rwxr-xr-x 1 root root   11200 Nov 10 14:27 mod_dumpio.so
-rwxr-xr-x 1 root root   11160 Nov 10 14:27 mod_echo.so
-rwxr-xr-x 1 root root   11184 Nov 10 14:27 mod_env.so
-rwxr-xr-x 1 root root   15312 Nov 10 14:27 mod_expires.so
-rwxr-xr-x 1 root root   23552 Nov 10 14:27 mod_ext_filter.so
-rwxr-xr-x 1 root root   15424 Nov 10 14:27 mod_file_cache.so
-rwxr-xr-x 1 root root   19424 Nov 10 14:27 mod_filter.so
-rwxr-xr-x 1 root root   23760 Nov 10 14:27 mod_headers.so
-rwxr-xr-x 1 root root   11192 Nov 10 14:27 mod_heartbeat.so
-rwxr-xr-x 1 root root   23592 Nov 10 14:27 mod_heartmonitor.so
-rwxr-xr-x 1 root root   52536 Nov 10 14:27 mod_include.so
-rwxr-xr-x 1 root root   28136 Nov 10 14:27 mod_info.so
-rwxr-xr-x 1 root root   11136 Nov 10 14:27 mod_lbmethod_bybusyness.so
-rwxr-xr-x 1 root root   11136 Nov 10 14:27 mod_lbmethod_byrequests.so
-rwxr-xr-x 1 root root   11128 Nov 10 14:27 mod_lbmethod_bytraffic.so
-rwxr-xr-x 1 root root   15328 Nov 10 14:27 mod_lbmethod_heartbeat.so
-rwxr-xr-x 1 root root   32312 Nov 10 14:27 mod_log_config.so
-rwxr-xr-x 1 root root   15400 Nov 10 14:27 mod_log_debug.so
-rwxr-xr-x 1 root root   15312 Nov 10 14:27 mod_log_forensic.so
-rwxr-xr-x 1 root root   11224 Nov 10 14:27 mod_logio.so
-rwxr-xr-x 1 root root  117120 Nov 10 14:27 mod_lua.so
-rwxr-xr-x 1 root root   19456 Nov 10 14:27 mod_macro.so
-rwxr-xr-x 1 root root   27752 Nov 10 14:27 mod_mime_magic.so
-rwxr-xr-x 1 root root   19528 Nov 10 14:27 mod_mime.so
-rwxr-xr-x 1 root root   61064 Nov 10 14:27 mod_mpm_event.so
-rwxr-xr-x 1 root root   31880 Nov 10 14:27 mod_mpm_prefork.so
-rwxr-xr-x 1 root root   48536 Nov 10 14:27 mod_mpm_worker.so
-rwxr-xr-x 1 root root   36008 Nov 10 14:27 mod_negotiation.so
-rwxr-xr-x 1 root root 1737472 MMM dd hh:ii mod_perl.so
-rwxr-xr-x 1 root root   52440 Nov 10 14:27 mod_proxy_ajp.so
-rwxr-xr-x 1 root root   48184 Nov 10 14:27 mod_proxy_balancer.so
-rwxr-xr-x 1 root root   19400 Nov 10 14:27 mod_proxy_connect.so
-rwxr-xr-x 1 root root   15296 Nov 10 14:27 mod_proxy_express.so
-rwxr-xr-x 1 root root   19384 Nov 10 14:27 mod_proxy_fcgi.so
-rwxr-xr-x 1 root root   11160 Nov 10 14:27 mod_proxy_fdpass.so
-rwxr-xr-x 1 root root   44192 Nov 10 14:27 mod_proxy_ftp.so
-rwxr-xr-x 1 root root   39960 Nov 10 14:27 mod_proxy_http.so
-rwxr-xr-x 1 root root   19464 Nov 10 14:27 mod_proxy_scgi.so
-rwxr-xr-x 1 root root  118848 Nov 10 14:27 mod_proxy.so
-rwxr-xr-x 1 root root   19360 Nov 10 14:27 mod_proxy_wstunnel.so
-rwxr-xr-x 1 root root   11168 Nov 10 14:27 mod_ratelimit.so
-rwxr-xr-x 1 root root   11176 Nov 10 14:27 mod_reflector.so
-rwxr-xr-x 1 root root   15312 Nov 10 14:27 mod_remoteip.so
-rwxr-xr-x 1 root root   15328 Nov 10 14:27 mod_reqtimeout.so
-rwxr-xr-x 1 root root   15360 Nov 10 14:27 mod_request.so
-rwxr-xr-x 1 root root   69056 Nov 10 14:27 mod_rewrite.so
-rwxr-xr-x 1 root root   40304 Nov 10 14:27 mod_sed.so
-rwxr-xr-x 1 root root   15336 Nov 10 14:27 mod_setenvif.so
-rwxr-xr-x 1 root root   11248 Nov 10 14:27 mod_slotmem_plain.so
-rwxr-xr-x 1 root root   15408 Nov 10 14:27 mod_slotmem_shm.so
-rwxr-xr-x 1 root root   15328 Nov 10 14:27 mod_socache_dbm.so
-rwxr-xr-x 1 root root   11200 Nov 10 14:27 mod_socache_memcache.so
-rwxr-xr-x 1 root root   23576 Nov 10 14:27 mod_socache_shmcb.so
-rwxr-xr-x 1 root root   15280 Nov 10 14:27 mod_speling.so
-rwxr-xr-x 1 root root  219456 Nov 10 14:27 mod_ssl.so
-rwxr-xr-x 1 root root   23472 Nov 10 14:27 mod_status.so
-rwxr-xr-x 1 root root   15280 Nov 10 14:27 mod_substitute.so
-rwxr-xr-x 1 root root   11176 Nov 10 14:27 mod_suexec.so
-rwxr-xr-x 1 root root   11120 Nov 10 14:27 mod_systemd.so
-rwxr-xr-x 1 root root   11144 Nov 10 14:27 mod_unique_id.so
-rwxr-xr-x 1 root root   15312 Nov 10 14:27 mod_unixd.so
-rwxr-xr-x 1 root root   11176 Nov 10 14:27 mod_userdir.so
-rwxr-xr-x 1 root root   15320 Nov 10 14:27 mod_usertrack.so
-rwxr-xr-x 1 root root   11112 Nov 10 14:27 mod_version.so
-rwxr-xr-x 1 root root   11192 Nov 10 14:27 mod_vhost_alias.so
-rwxr-xr-x 1 root root   19488 Nov 10 14:27 mod_watchdog.so

まずはファイルの位置を確認。

/usr/lib64/httpd/modules/mod_perl.so に生成されていることが分かりました。

LoadModule

# vi /etc/httpd/conf.modules.d/10-perl.conf

LoadModule perl_module modules/mod_perl.so

今回は httpd.conf/etc/httpd/conf.modules.d/ 下の conf ファイルを読み込ませるワイルドカード記述があったので、 Perl 用の設定ファイルを新規作成します。読み込みは後勝ちだったはずなので、番号は 10 にしました。

仮想ホストの設定 (http)

# vi /etc/httpd/conf.d/sample.conf

<VirtualHost *:80>
    DocumentRoot "/var/www/samplesite/web"
    ServerName www.lvh.me
    ServerAlias lvh.me
    ScriptAlias /cgi-bin/ /var/www/samplesite/web/cgi-bin/
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^lvh.me$
    RewriteRule ^(.*)$       http://www.lvh.me/$1 [R=301,L]
    <Directory "/var/www/samplesite/web">
        allow from all
        AllowOverride All
        SetHandler perl-script
        PerlHandler ModPerl::Registry
        PerlSendHeader On
        Options +ExecCGI
        Require all granted
        AddHandler cgi-script .cgi .pl
        DirectoryIndex index.html index.cgi
    </Directory>
#    RewriteEngine on
#    RewriteCond %{SERVER_NAME} =www.lvh.me
#    RewriteRule ^ https://%{SERVER_NAME}:WEB_HOST_PORTSSL%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

仮想ホストの設定 (https)

# vi /etc/httpd/conf.d/sample_ssl.conf 
<IfModule mod_ssl.c>
    <VirtualHost *:443>
        DocumentRoot "/var/www/samplesite/web"
        ServerName www.lvh.me
        ServerAlias lvh.me
        ScriptAlias /cgi-bin/ /var/www/samplesite/web/cgi-bin/
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^lvh.me$
        RewriteRule ^(.*)$       https://www.lvh.me/$1 [R=301,L]
        <Directory "/var/www/samplesite/web">
            allow from all
            AllowOverride All
            SetHandler perl-script
            PerlHandler ModPerl::Registry
            PerlSendHeader On
            Options +ExecCGI
            Require all granted
            AddHandler cgi-script .cgi .pl
            DirectoryIndex index.html index.cgi
        </Directory>
        SSLEngine on
        SSLCertificateFile /etc/ssl/private/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
    </VirtualHost>
</IfModule>

共に

SetHandler perl-script
PerlHandler ModPerl::Registry
PerlSendHeader On

の3行を追加。

# /usr/sbin/httpd -DFOREGROUND &
[1] 5936
#

これで Apache を起動して、動作確認。

5.8.9のバージョンが表示された
5.8.9のバージョンが表示された

勝った!第二部・完!

参考

Perl 5.8

configure 時のオプションについて

スレッド機能

mod_perl

CGI と mod_perl

apxs

シンボリックリンク

この記事を書いた人

アルム=バンド

フロントエンド・バックエンド・サーバエンジニア。LAMPやNodeからWP、Gulpを使ってejs,Scss,JSのコーディングまで一通り。たまにRasPiで遊んだり、趣味で開発したり。