さくらインターネットにphp5をインストール
メジャーな検索エンジンで検索すれば、既にいくつかのエントリが見つかるけれど、あくまで自分用のメモということで。
今回インストールしたphpのバージョンは、php-5.2.5です。このバージョンを既存のブログエントリ通りインストールを行うと"Internal Server Error"と表示されて動作しません。実は、5.2.2以前と5.2.3以降のバージョンでは若干仕様が異なるためそうなってしまうようです。実はこのエントリを残そうとしたのもその理由です。
結論を先に述べてしまうと、php-5.2.2以前の場合は$HOME/bin/php5をcgi実行モジュールとしているが、php-5.2.3以降の場合は$HOME/bin/php-cgi5であるため、php-5.2.2以前の通りに$HOME/bin/php5でcgiを実行しようとするとInternal Server Errorが出てしまうのである。
大まかな手順
既存のphp4のconfigureの確認
$HOME/www/phpinfo.phpなどを作成してconfigreの状態を確認。
2007-11-25時点では下記の通りでした
'./configure' '--prefix=/usr/local/php-4.4.7' '--enable-force-cgi-redirect' '--enable-mbstring' '--enable-mbregex' '--enable-versioning' '--with-openssl=/usr' '--with-iconv=/usr/local' '--with-gd' '--with-zlib=/usr' '--with-jpeg-dir=/usr/local' '--with-png-dir=/usr/local' '--with-ttf' '--with-freetype-dir=/usr/local' '--with-mysql=/usr/local' '--enable-soap' '--with-curl' '--enable-xslt' '--with-xslt-sablot=/usr/local' '--with-dom' '--with-dom-xslt' '--with-gettext=/usr/local' '--enable-exif'
php.netからphp-5.2.5.tar.gzをダウンロード
http://jp.php.net/get/php-5.2.5.tar.gz/from/a/mirrorからダウンロード。
自分のホームディレクトリに任意のディレクトリを作成し、そこへダウンロードします。
mkdir $HOME/tmp
cd $HOME/tmp
wget http://jp.php.net/get/php-5.2.5.tar.gz/from/this/mirror
configre
nazokingさんのエントリ、http://d.hatena.ne.jp/nazoking/20041213/1102925275と、先ほどのconfigureの内容を比較しつつ、configureのオプションを修正します。
自分は下記のようにしました。
./configure --prefix=$HOME --with-config-file-path=$HOME/etc --program-suffix=5 --with-pear=$HOME/share/pear5 --enable-force-cgi-redirect --enable-mbstring=all --enable-mbregex --enable-mbstr-enc-trans --enable-versioning --enable-trans-sid --with-mysql --with-openssl=/usr --with-soap=yes --with-zlib=/usr --with-gd=/usr/local --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-ttf --with-png-dir=/usr --with-curl --with-iconv=/usr/local --enable-soap --enable-xslt --with-xslt-sablot=/usr/local --with-dom --with-dom-xslt --with-gettext=/usr/local --enable-exif
make、make install
make、make installを実行します。存在していないディレクトリは先に着くっておいた方が良いかもしれません。
ローカルな設定
下記の作業を行います。
実行ファイルのコピー(Or ハードリンク)
インストールしたphp5がcgiとして実行できるように、実行ファイルをコピーします。シンボリックリンクでは動作しませんでした。
mkdir -p $HOME/www/cgi-bin
・php-5.2.2以前の場合、
cp $HOME/bin/php5 $HOME/www/cgi-bin/php5.cgi
・php-5.2.3以降の場合、
cp $HOME/bin/php-cgi5 $HOME/www/cgi-bin/php5.cgi
とりあえずphpinfo()で確認
phpinfoでphpのバージョンが5.2.5になっていることを確認します。