Top/Devel/PHP/バージョンの違うPHPでの動作確認を簡単に

バージョンの違うPHPでの動作確認を簡単に の変更点はてなブックマーク


バージョンの違うPHPを共存・同居させる。~
以下は CGI版PHP での話です。~
DSO版PHP では、[[PHP-users 保存書庫 バージョン違いのPHPの同居  >http://ns1.php.gr.jp/pipermail/php-users/2003-September/thread.html#18255]] を見たところ、~
ちょっと面倒かなーという感じがしたもので逃げました。

*Apacheでの手順
+以下のようにしてCGI版PHPをインストール。mbstringなどはお好みで。
++PHP3.x.x
 export PHP_PREFIX="/usr/local/php-3.0.18"
 ./configure --enable-cgi --disable-cli --disable-pear \
 --enable-force-cgi-redirect --with-config-file-path=$PHP_PREFIX/lib/
 make
 mkdir -p $PHP_PREFIX/lib
 cp php $PHP_PREFIX/
 cp php3.ini-dist $PHP_PREFIX/lib/php3.ini
++PHP4.x.x
 export PHP_PREFIX="/usr/local/php-4.3.2"
 ./configure --enable-cgi --disable-cli --disable-pear \
 --enable-force-cgi-redirect --with-config-file-path=$PHP_PREFIX/lib/
 make
 mkdir -p $PHP_PREFIX/lib
 cp sapi/cgi/php $PHP_PREFIX
 cp php.ini-dist $PHP_PREFIX/lib/php.ini
++PHP5.x.x
 export PHP_PREFIX="/usr/local/php-5.0.3"
 ./configure --enable-cgi --disable-cli --disable-pear \
 --enable-force-cgi-redirect --with-config-file-path=$PHP_PREFIX/lib/
 make
 mkdir -p $PHP_PREFIX/lib
 cp sapi/cgi/php $PHP_PREFIX
 cp php.ini-dist $PHP_PREFIX/lib/php.ini
+httpd.confを開き、以下を追記。((ここではすでに.phpはDSO版PHPで動作するように設定しているものとしている。))
 ScriptAlias /php-3018/ "/usr/local/php-3.0.18/"
 AddType application/x-httpd-php-3018 .p3018
 Action application/x-httpd-php-3018 "/php-3018/php"
 
 ScriptAlias /php-432/ "/usr/local/php-4.3.2/"
 AddType application/x-httpd-php-432 .p432
 Action application/x-httpd-php-432 "/php-432/php"
 
 ScriptAlias /php-433/ "/usr/local/php-4.3.3/"
 AddType application/x-httpd-php-433 .p433
 Action application/x-httpd-php-433 "/php-433/php"
 
 ScriptAlias /php-503/ "/usr/local/php-5.0.3/"
 AddType application/x-httpd-php-503 .p503
 Action application/x-httpd-php-503 "/php-503/php"
+Apacheを再起動。
+hoge.php を hoge.p3018, hoge.p432, hoge.p503 などとしてコピー。

*[[Apache for Win32>http://httpd.apache.org/download.cgi]]での手順
以下、動作させるスクリプトを hoge.php と仮定。

+[[PHP: Releases>http://www.php.net/releases.php]] からWindows binary (zip)を落としてくる。
+c:\などに解凍。
+php.ini-distをphp.iniにリネーム。
+php.iniを開き、mbstringなどをお好みで。
+httpd.confを開き、以下を追記。
 ScriptAlias /php/ "c:/php-4.3.10-Win32/"
 AddType application/x-httpd-php .php
 Action application/x-httpd-php "/php/php.exe"
 
 ScriptAlias /php-3017/ "c:/php-3.0.17-win32/"
 AddType application/x-httpd-php-3017 .p3017
 Action application/x-httpd-php-3017 "/php-3017/php.exe"
 
 ScriptAlias /php-432/ "c:/php-4.3.2-Win32/"
 AddType application/x-httpd-php-432 .p432
 Action application/x-httpd-php-432 "/php-432/php.exe"
 
 ScriptAlias /php-433/ "c:/php-4.3.3-Win32/"
 AddType application/x-httpd-php-433 .p433
 Action application/x-httpd-php-433 "/php-433/php.exe"
 
 ScriptAlias /php-503/ "c:/php-5.0.3-Win32/"
 AddType application/x-httpd-php-503 .p503
 Action application/x-httpd-php-503 "/php-503/php-cgi.exe"
+Apacheを再起動。
+hoge.php を hoge.p3017, hoge.p432, hoge.p503 などとしてコピー。

*[[AN HTTPD>http://www.st.rim.or.jp/~nakata/]]での手順
以下、動作させるスクリプトを hoge.php と仮定。

+[[PHP: Releases>http://www.php.net/releases.php]] からWindows binary (zip)を落としてくる。
+c:\などに解凍。
+php.ini-distをphp.iniにリネーム。
+php.iniを開き、 cgi.force_redirect = 0 にする(PHP3では不要)。mbstringはお好みで。
+AN HTTPDを起動し、オプション一般で次のように設定する。また、設定時には「一般パスでも実行する」「PATH_TRANSLATEDを使う」にチェックを入れる。
|拡張子|実行プログラム|h
|.php|c:\php-4.3.10-Win32\php.exe|
|.p3017|c:\php-3.0.17-win32\php.exe -c c:\php-3.0.17-win32|
|.p432|c:\php-4.3.2-Win32\php.exe|
|.p433|c:\php-4.3.3-Win32\php.exe|
|.p503|c:\php-5.0.3-Win32\php-cgi.exe|
+hoge.php を hoge.p3017, hoge.p432, hoge.p503 などとしてコピー。

*備考
-これで、hoge.p432はPHP4.3.2、hoge.p503はPHP5.0.3で実行され(ているような気がす)る。~
PukiWikiのindex.phpをindex.p432としてコピーしたものでは[[PukiWiki-dev:BugTrack/761]]の不具合も再現してるので、とりあえずOK?
-スクリプトをコピーするのではなく、[[ハードリンク/ジャンクション作成ツール>http://homepage1.nifty.com/emk/symlink.html]]でハードリンクを張れば、ソースの改変も楽々 :)
-CGI版PHPではHTTP認証のフックはできないので注意。

*参考
-[[[neko::blog: PHP4のインストールによくはま(る|った)メモ]>http://blog.unknown.jp/mt/archives/000468.html]]
-[[PHP>http://d.tir.jp/pw?PHP]]
-[[AN HTTPDでPHPを動かす>http://homepage1.nifty.com/yito/anhttpd/faq/php.html]]
-[[PHP: Apache 2.0サーバ - Manual>http://www.php.net/manual/ja/install.apache2.php#install.apache2.windows]]

*コメント等ありましたらどうぞ :)
#pcomment(,5,reply)

*Amazon
#amazon(479733245X,left)
#amazon(4844320254,left)
#amazon(4798119865,left)
差分 一覧