2008年04月09日

PHP4(CGI版)とPHP5(モジュール版)を同居

仕事で古い案件のリプレイス。
テストサーバで動かそうとしたが、PHP5のため動かない。
互換モードの設定をしてもダメ。SQLite2を使っている為だ。
Googleで調べる限りではSQLite2をCentOS5標準のPHP5で動かすのは難しいらしい。(PDO経由で使えというポリシーとのこと)

しょうがないので、CGI版PHP4とRPMのPHP5を共存させる方向で動かすことに。

参考ページはこの2つ
http://www.phppro.jp/news/60
http://wiki.poyo.jp/read/Writing/kiwameru_php_vol.1/php4_and_php5/10.02.build_install_php4

以下の通りconfigure
./configure --enable-force-cgi-redirect --prefix=/usr/local/php4 --with-pgsql --with-mysql=/usr --enable-track-vars --enable-mbstring --enable-mbstr-enc-trans --enable-trans-sid --with-gd --with-zlib --with-jpeg-dir=/usr/lib --with-png-dir=/usr/lib --with-ftp --with-curl=/usr/lib --disable-cli --without-pear

--enable-force-cgi-redirectがキモみたい。

あとはhttpd.confでバーチャルホストを切る


DocumentRoot /home/hoge/public_html
ServerName hoge.example.jp
ScriptAlias /cgi-bin/ "/home/hoge/cgi-bin/"
Action php4-script /cgi-bin/php
AddHandler php4-script .php

Options +ExecCGI

「/usr/local/php4/bin/php」から「/home/hoge/cgi-bin/php」にシンボリックリンクをはっておけばOK

パーミッションの変更も、「#!/usr/local/bin/php」とかもいらないみたい。便利だ。

Posted by matsui at 2008年04月09日 14:58

Comments
Post a comment









Remember personal info?