Ubuntu8.10 + Apache2.2.11 + PHP5.2.9

ApachePHPの最新版を入れたいので、例によってソースからコンパイル
UbuntuDebianなので、パッケージ管理はapt。
(参照: 第04回 「apt-get, dpkg コマンドでパッケージ管理」
まあ、めんどくさいのでSynapticパッケージマネージャのお世話になったりもするけれど。
とりあえず、先にcheckinstallを入れておく。

# sudo apt-get install checkinstall
...
# wget http://ftp.riken.jp/net/apache/httpd/httpd-2.2.11.tar.gz
# tar zxvf httpd-2.2.11.tar.gz
# cd httpd-2.2.11
# ./configure --with-ldap \
              --enable-mods-shared=all
...
# make
...
# sudo checkinstall
...
# sudo dpkg -i httpd_2.2.11-1_i386.deb
...
# dpkg -l httpd
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ 名前         バージョ   説明
+++-==============-==============-============================================
ii  httpd          2.2.11-1       Apache 2.2.11

コンパイル時、特に指定しなかったので、インストール先は /usr/local/apache2 となる。
phpをインストールする前に、libjpegとlibpngが入っているかどうか確認。

# dpkg -l libjpeg*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ 名前           バージョン  説明
+++-================-================-================================================
ii  libjpeg62        6b-14            The Independent JPEG Group"s JPEG runtime librar

# dpkg -l libpng*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ 名前           バージョン  説明
+++-================-================-================================================
ii  libpng12-0       1.2.27-1ubuntu0. PNG library - runtime
un  libpng12-dev     <なし>         (説明 (description) がありません)

入ってるみたい。

# dpkg -L libjpeg62
/.
/usr
/usr/lib
/usr/lib/libjpeg.so.62.0.0
/usr/share
/usr/share/doc
/usr/share/doc/libjpeg62
/usr/share/doc/libjpeg62/copyright
/usr/share/doc/libjpeg62/changelog.gz
/usr/share/doc/libjpeg62/README.gz
/usr/share/doc/libjpeg62/changelog.Debian.gz
/usr/lib/libjpeg.so.62

# dpkg -L libpng12-0
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libpng12-0
/usr/share/doc/libpng12-0/changelog.gz
/usr/share/doc/libpng12-0/README.gz
/usr/share/doc/libpng12-0/TODO
/usr/share/doc/libpng12-0/ANNOUNCE
/usr/share/doc/libpng12-0/KNOWNBUG
/usr/share/doc/libpng12-0/README.Debian
/usr/share/doc/libpng12-0/copyright
/usr/share/doc/libpng12-0/changelog.Debian.gz
/usr/share/doc/libpng12-0/libpng-1.2.27.txt.gz
/usr/share/doc-base
/usr/share/doc-base/libpng12
/usr/lib
/usr/lib/libpng12.so.0.27.0
/usr/lib/libpng12.so.0

前の経験を基に、libjpeg.soとlibpng.soはシンボリックリンクで作っておくことに。

# cd /usr/share
# ls -l libjpeg*
lrwxrwxrwx 1 root root     17 2009-04-08 11:14 libjpeg.so.62 -> libjpeg.so.62.0.0
-rw-r--r-- 1 root root 125316 2007-10-01 23:36 libjpeg.so.62.0.0

# sudo ln -s libjpeg.so.62.0.0 libjpeg.so

# ls -l libpng*
lrwxrwxrwx 1 root root     18 2009-04-08 11:33 libpng12.so.0 -> libpng12.so.0.27.0
-rw-r--r-- 1 root root 149288 2009-03-06 04:31 libpng12.so.0.27.0

# sudo ln -s libpng12.so.0.27.0  libpng.so

で、PHP

# wget http://www.php.net/get/php-5.2.9.tar.gz/from/a/mirror
# tar zxvf php-5.2.9.tar.gz
# cd php-5.2.9

# ./configure --with-pic \
              --with-pear \
              --with-bz2 \
              --with-curl \
              --with-png-dir=/usr/share \
              --enable-gd-native-ttf \
              --with-gettext \
              --with-gmp \
              --with-iconv \
              --with-jpeg-dir=/usr/share \
              --with-openssl \
              --with-zlib \
              --enable-exif \
              --enable-ftp \
              --enable-magic-quotes \
              --enable-sockets \
              --with-kerberos \
              --enable-calendar \
              --with-mime-magic=/usr/local/apache2/conf/magic \
              --with-sqlite \
              --with-apxs2=/usr/local/apache2/bin/apxs \
              --with-mysql \
              --with-gd \
              --enable-zend-multibyte \
              --enable-mbstring \
              --enable-mbregex \
              --enable-cgi
...
configure: error: xml2-config not found. Please check your libxml2 installation.
# apt-get install libxml2
...
libxml2 はすでに最新バージョンです。

ん?

# dpkg -l libxml2*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ 名前           バージョン  説明
+++-================-================-================================================
ii  libxml2          2.6.32.dfsg-4ubu GNOME XML library
ii  libxml2-utils    2.6.32.dfsg-4ubu XML utilities

# apt-get install libxml2-dev
...
# ./configure (略)
...
# configure: error: Cannot find OpenSSL"s <evp.h>

# whereis openssl
openssl: /usr/bin/openssl /usr/share/man/man1/openssl.1ssl.gz

エラーメッセージでググると大抵「openssl-develをインストールしろ」と出てくるけれど、Ubuntuの場合「libssl-dev」になるらしい。

# apt-get install libssl-dev

# ./configure (略)
...
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution

# sudo apt-get install libbz2-dev
...
# ./configure (略)
...
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/

# sudo apt-get install curl

curlのエラーでググったらうちのサイトがトップでひっかかって吹いた。

# sudo apt-get install libcurl4-openssl-dev
...
# ./configure --with-pic \
              --with-pear \
              --with-bz2 \
              --with-curl \
              --with-png-dir=/usr/share \
              --enable-gd-native-ttf \
              --with-gettext \
              --with-gmp \
              --with-iconv \
              --with-jpeg-dir=/usr/share \
              --with-openssl \
              --with-zlib \
              --enable-exif \
              --enable-ftp \
              --enable-magic-quotes \
              --enable-sockets \
              --with-kerberos \
              --enable-calendar \
              --with-mime-magic=/usr/local/apache2/conf/magic \
              --with-sqlite \
              --with-apxs2=/usr/local/apache2/bin/apxs \
              --with-mysql \
              --with-gd \
              --enable-zend-multibyte \
              --enable-mbstring \
              --enable-mbregex \
              --enable-cgi \
              --with-curl=/usr/bin ←増えた
...
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.
...
# sudo apt-get install libpng12-dev
...
# ./configure (略)
...
checking for GNU MP support... yes
configure: error: Unable to locate gmp.h

# sudo apt-get install libgmp3-dev
...
# ./configure (略)
...
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!

# dpkg -l mysql*
mysql* に一致するパッケージが見つかりません。

入ってないのかy

# sudo apt-get install mysql-server mysql-client libmysqlclient15-dev


リモートでターミナル使って作業してるのに、いきなりカラーな画面が出るとびびるじゃんか・・・!

# ./configure (略)
...
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

# make
...
/home/username/tmp/php-5.2.9/ext/gd/libgd/gd_jpeg.c:38:21: error: jpeglib.h: No such file or directory
(以下67行)
make: *** [ext/gd/libgd/gd_jpeg.lo] エラー 1

まて。どっかで見たことあるぞ。
・・・ああ、CentOSに入れたとき([id:nain:20090327:1238483504])か・・・。

# sudo apt-get libjpeg-dev
...
# make clean
...
# make
...
# make install

終了。

/usr/local/apach2/conf/httpd.conf

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
#    DirectoryIndex index.html
    DirectoryIndex index.php index.cgi index.html ←.phpと.cgiを追加してみる
</IfModule>
...
# User home directories
#Include conf/extra/httpd-userdir.conf ←コメント外す
...
# 末尾に以下を追加
<FilesMatch "\.ph(p[2-6]?|tml)$">
  SetHandler application/x-httpd-php
</FilesMatch>

<FilesMatch "\.phps$">
  SetHandler application/x-httpd-php-source
</FilesMatch>

/usr/local/apach2/conf/extra/httpd-userdir.conf

<Directory "/home/*/public_html">
#    AllowOverride FileInfo AuthConfig Limit Indexes
#    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    AllowOverride FileInfo AuthConfig Limit ←お好みで
    Options MultiViews FollowSymLinks ExecCGI ←お好みで
    <Limit GET POST OPTIONS>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>

これでとりあえずの設定はおk。

# cd /usr/local/apache2
# sudo cp apachectl /etc/init.d/apache
# sudo update-rc.d apache defaults 85 15

Apache自動起動の設定をして完了。