目次
CentOS6 に PHP 5.1.6 をインストールする
以下の内容は、CentOS 6.3 に PHP 5.3.18 (Remiリポジトリ) と MySQL 5.5.28 (Remiリポジトリ) がインストールされた環境に、PHP 5.1.6 を混在させる方法です。
PHP の古いバージョンを探す
古いバージョンはUnsupported Historical Releasesより探すことができる。
少し古い OpenSSL をソースからインストール
CentOS 6.3 の OpenSSL が 1.0.0 なので、Bug #53547 Cannot compile PHP with OpenSSL のバグで PHP をビルドできないようである。
$ rpm -qa | grep openssl openssl-1.0.0-25.el6_3.1.x86_64 openssl-devel-1.0.0-25.el6_3.1.x86_64
バグを回避する為に、少し古い OpenSSL をソースからインストールする。
- OpenSSL 0.9.8 のソースをダウンロードする。
$ cd ~/work $ curl -O http://www.openssl.org/source/openssl-0.9.8x.tar.gz
※openssl-0.9.8e.tar.gz だと x86_64 でバグでビルドできない。
#2094: BUG: 0.9.8x md5-x86_64.s:41: Error: 0xd76aa478 out range of signed 32bit displacement - ダウンロードした圧縮ファイルを解凍する。
$ tar zxvf openssl-0.9.8x.tar.gz
- configure する。(openssl は ./config)
$ cd openssl-0.9.8x $ ./config --prefix=/usr/local shared
- ビルドしてインストールする。
$ make $ sudo make install LIBDIR=lib64
※本家の tar ball は x86_64 でも /usr/local/lib にインストールされるので、/usr/local/lib64に配置するように LIBDIR=lib64 を指定する。
PHP をソースからインストール
- ソースをダウンロードする。
$ cd work $ curl -O http://museum.php.net/php5/php-5.1.6.tar.bz2
- ダウンロードした圧縮ファイルを解凍する。
$ tar jxvf php-5.1.6.tar.bz2
- ビルドに必要なパッケージをインストールする。
$ sudo yum install zlib-devel openssl-devel db4-devel pcre-devel $ sudo yum install libicu libicu-devel gettext-devel gd-devel $ sudo yum install readline-devel libxml2-devel libxslt-devel $ sudo yum install libcurl-devel $ sudo yum install mysql-devel postgresql-devel --enablerepo=remi
- configure する。
$ cd php-5.1.6 $ ./configure \ --prefix=/usr/local/lib64/php-5.1.6 \ --with-config-file-path=/usr/local/lib64/php-5.1.6 \ --enable-cli \ --with-libdir=lib64 \ --enable-mbstring=shared \ --enable-intl=shared \ --with-icu-dir=shared \ --with-gettext=shared \ --with-pcre-regex=shared \ --with-pcre-dir=shared \ --with-readline=shared \ --with-libxml-dir=/usr/bin/xml2-config \ --enable-soap \ --enable-wddx \ --with-xmlrpc \ --with-xsl=shared \ --enable-force-cgi-redirect \ --enable-mbstr-enc-trans \ --enable-track-vars \ --enable-mbregex \ --with-gd=shared \ --with-jpeg-dir=/usr/include \ --with-png-dir=/usr/include \ --enable-gd-native-ttf \ --with-openssl=/usr/local \ --with-zlib=shared \ --with-curl=shared \ --enable-ftp=shared \ --with-mysql=shared \ --with-mysqli=shared \ --with-pdo-mysql=shared \ --with-pdo-sqlite=shared \ --with-pgsql=shared \ --enable-sqlite-utf8 \ --enable-zend-multibyte \ --program-suffix=51 \ 2>&1 | tee configure_log.txt
※configure のオプション一覧は ./configure –help で確認できる。
- curl の interface.c がエラーになるので修正する。
以下の2つの行をコメントアウトする。
REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII);
REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION);$ cp ext/curl/interface.c ext/curl/interface.c.org $ vi ext/curl/interface.c $ diff ext/curl/interface.c ext/curl/interface.c.org 274c274 < //REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII); --- > REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII); 314c314 < //REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION); --- > REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION);
- mysqli の mysqli.c がエラーになるので、mysql.h を修正する。
enum mysql_protocol_type { MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET, MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY };
と
typedef struct character_set { unsigned int number; /* character set number */ unsigned int state; /* character set state */ const char *csname; /* collation name */ const char *name; /* character set name */
の間に
/* There are three types of queries - the ones that have to go to the master, the ones that go to a slave, and the adminstrative type which must happen on the pivot connectioin */ enum mysql_rpl_type { MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN };
を挿入する。
$ sudo cp /usr/include/mysql/mysql.h /usr/include/mysql/mysql.h.org $ sudo vi /usr/include/mysql/mysql.h $ diff /usr/include/mysql/mysql.h /usr/include/mysql/mysql.h.org 227,236d226 < /* < There are three types of queries - the ones that have to go to < the master, the ones that go to a slave, and the adminstrative < type which must happen on the pivot connectioin < */ < enum mysql_rpl_type < { < MYSQL_RPL_MASTER, MYSQL_RPL_SLAVE, MYSQL_RPL_ADMIN < }; <
- mysqli の mysqli_api.c がエラーになるので修正する。
145行目以降4カ所:bind[ofs].buffer = (gptr)&Z_DVAL_PP(args[i]);
bind[ofs].buffer = &Z_DVAL_PP(args[i]);
※(gptr)にキャストしている部分をすべて除去する。
$ cp ext/mysqli/mysqli_api.c ext/mysqli/mysqli_api.c.org $ vi ext/mysqli/mysqli_api.c $ diff ext/mysqli/mysqli_api.c ext/mysqli/mysqli_api.c.org 145c145 < bind[ofs].buffer = &Z_DVAL_PP(args[i]); --- > bind[ofs].buffer = (gptr)&Z_DVAL_PP(args[i]); 151c151 < bind[ofs].buffer = &Z_LVAL_PP(args[i]); --- > bind[ofs].buffer = (gptr)&Z_LVAL_PP(args[i]); 601c601 < stmt->stmt->params[i].buffer = &Z_LVAL_PP(&stmt->param.vars[i]); --- > stmt->stmt->params[i].buffer = (gptr)&Z_LVAL_PP(&stmt->param.vars[i]); 605c605 < stmt->stmt->params[i].buffer = &Z_LVAL_PP(&stmt->param.vars[i]); --- > stmt->stmt->params[i].buffer = (gptr)&Z_LVAL_PP(&stmt->param.vars[i]);
- ビルドしてインストールする。
$ make $ sudo make install
ビルドした PHP をテストする
$ cp php.ini-dist php.ini $ vi php.ini
php.ini に extension をロードするように追記する。
extension=modules/pcre.so
テストを実行する。
$ make test ~省略~ PASS XMLWriter: libxml2 XML Writer, file buffer, flush [ext/xmlwriter/tests/OO_001.phpt] PASS XMLWriter: libxml2 XML Writer, membuffer, flush [ext/xmlwriter/tests/OO_002.phpt] PASS XMLWriter: libxml2 XML Writer, membuffer, flush, text, attribute [ext/xmlwriter/tests/OO_003.phpt] PASS XMLWriter: libxml2 XML Writer, file buffer, flush [ext/xmlwriter/tests/OO_004.phpt] PASS XMLWriter: libxml2 XML Writer, comments [ext/xmlwriter/tests/OO_005.phpt] PASS XMLWriter: libxml2 XML Writer, startDTD/writeElementNS [ext/xmlwriter/tests/OO_006.phpt] FAIL XMLWriter: libxml2 XML Writer, Elements & Attributes [ext/xmlwriter/tests/OO_007.phpt] PASS XMLWriter: libxml2 XML Writer DTD Element & Attlist [ext/xmlwriter/tests/OO_008.phpt] FAIL XMLWriter: PI, Comment, CDATA [ext/xmlwriter/tests/OO_009.phpt] ===================================================================== TIME END 2012-10-30 23:23:40 ===================================================================== TEST RESULT SUMMARY --------------------------------------------------------------------- Exts skipped : 56 Exts tested : 23 --------------------------------------------------------------------- Number of tests : 2264 1666 Tests skipped : 598 ( 26.4%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 13 ( 0.6%) ( 0.8%) Tests passed : 1653 ( 73.0%) ( 99.2%) --------------------------------------------------------------------- Time taken : 52 seconds ===================================================================== ===================================================================== FAILED TEST SUMMARY --------------------------------------------------------------------- Testing $argc and $argv handling (GET) [tests/basic/011.phpt] Test 7: DTD tests [ext/dom/tests/dom007.phpt] iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt] date_sunrise() and date_sunset() functions [ext/standard/tests/general_functions/sunfuncts.phpt] Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect), using UTF-* [ext/xml/tests/bug32001.phpt] Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM) [ext/xml/tests/bug35447.phpt] XMLReader: libxml2 XML Reader, DTD [ext/xmlreader/tests/008.phpt] XMLReader: accessing empty and non existing attributes [ext/xmlreader/tests/012.phpt] Bug #38431 (xmlrpc_get_type() crashes PHP on objects) [ext/xmlrpc/tests/bug38431.phpt] XMLWriter: libxml2 XML Writer, Elements & Attributes [ext/xmlwriter/tests/007.phpt] XMLWriter: PI, Comment, CDATA [ext/xmlwriter/tests/009.phpt] XMLWriter: libxml2 XML Writer, Elements & Attributes [ext/xmlwriter/tests/OO_007.phpt] XMLWriter: PI, Comment, CDATA [ext/xmlwriter/tests/OO_009.phpt] ===================================================================== You may have found a problem in PHP. We would like to send this report automatically to the PHP QA team, to give us a better understanding of how the test cases are doing. If you don't want to send it immediately, you can choose "s" to save the report to a file that you can send us later. Do you want to send this report now? [Yns]: s
参考文献
第26回 早速PHPをビルド! そしてテスト!
Apache2で複数バージョンのPHPを使い分ける
PHP: インストールと設定 - Manual
CentOS 6.3に「–with-openssl」オプション付きでPHP 5.1/5.2系をインストールしようとするとエラー → 解決
Compiling PHP-5.1.6 on Fedora 9
[Solved] Error in Installing php5-mysqli - The FreeBSD Forums
PHP mysqlnd svn commit: r415 - in trunk: php5/ext/mysqli php6/ext/mysqli
php5 のbuild 3 : まったり生活記:のーたれ ~脳内垂れ流し~