Mar
27
2010

php-5.3.2

20:55 pm

php-5.2.10にバクがあるため、最新版の5.3.2にアップグレードすることにより、バグの解消を試みました。
PHP 5 のインストールを参考に、PHP のインストールと実行には libxml2 が、GD ライブラリを有効にするためには zlib と libpng が必要とのことなので、まずはこの三つをインストールします。
$ sudo aptitude install libxml2-dev zlib1g-dev libpng-dev

また、apxs2 が必要になるとのことですが、$ sudo find / -name apxs2としてもfindできなかったので、
$ sudo aptitude install apache2-prefork-dev
として、apxs2 をインストールしました。

以下のプロセスは、Ubuntu 9.0.4 へ PHP5.3.0 動作環境を作るを参考にしました。というか、ほとんどそのまんまです。

phpソースのダウンロードと展開
以下のように、現時点の最新版をダウンロードしました。
$ cd /usr/local/lib
$ sudo wget http://jp2.php.net/get/php-5.3.2.tar.gz/from/jp.php.net/mirror
$ sudo tar zxvf php-5.3.2.tar.gz
$ cd ./php-5.3.2

ソースを展開したら、次にconfigureを実行します。configureには非常に多くのオプションがあるので、詳細については./configure –helpを実行してください。
オプションとして–with-apxs2を指定してApacheに組み込むようにします。もしエラーが発生した場合はapxsが存在しない可能性があります。apxsはhttpd-develのパッケージをインストールすれば同時にインストールされます。apxsが存在するのにエラーとなっている場合は直接パスを –with-apxs2=/usr/sbin のように指定します。
–enable-mbstring –enable-zend-multibyteは日本語環境を使用するためのオプションです。–with-pgsql、–with-mysqlはその名の通り、PostgreSQLとMySQLを使用するためのオプションです。こちらはパスを指定することもできるので、ソースからインストールしていて、パスを指定しなければならない場合には、きちんと指定しましょう。

自分の場合は、以下でconfigureしました。

./configure --prefix=/usr/local/lib/php-5.3.2 --with-apxs2=/usr/bin/apxs2 --enable-pcntl --enable-mbstring --enable-mbregex --enable-zend-multibyte --with-mysql --with-mysqli --with-mcrypt --with-gd --with-openssl --with-zlib --with-pgsql --with-pear=/usr/local/lib/php-5.3.2

すると、
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
とエラーがでてしまったので、
$ sudo aptitude install libmcrypt4 libmcrypt-dev
として、再度、
$ sudo ./configure –pre…..を試みると、
Thank you for using PHP.
となりました。

configureが終了したら、あとはmakeを実行します。実行しているマシンパワーによってはかなり時間がかかることもあります。makeまではrootで行う必要はありませんが、make installはrootで実行します。

$ sudo su
# make
とすると、

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
invertedregexiterator.inc
directorygraphiterator.inc
directorytreeiterator.inc
pharcommand.inc
phar.inc
Build complete.
Don't forget to run 'make test'.

と、maketest をしなさいと言われたので、
# maketest
を実行してみました。
結果は、以下のとおりでした。

=====================================================================
EXPECTED FAILED TEST SUMMARY
---------------------------------------------------------------------
output buffering - fatalism [tests/output/ob_011.phpt]
Inconsistencies when accessing protected members [Zend/tests/access_modifiers_008.phpt]
Inconsistencies when accessing protected members - 2 [Zend/tests/access_modifiers_009.phpt]
Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770.phpt]
Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770_2.phpt]
Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770_3.phpt]
SimpleXML: array casting bug [ext/simplexml/tests/034.phpt]
=====================================================================
=====================================================================
WARNED TEST SUMMARY
---------------------------------------------------------------------
via [ext/pdo_sqlite/tests/common.phpt]
	SQLite PDO Common: Bug #34630 (inserting streams as LOBs) [ext/pdo_sqlite/tests/bug_34630.phpt] (warn: XFAIL section but test passes)
via [ext/sqlite/tests/pdo/common.phpt]
	SQLite2 PDO Common: Bug #34630 (inserting streams as LOBs) [ext/sqlite/tests/pdo/bug_34630.phpt] (warn: XFAIL section but test passes)
=====================================================================

# make install
すると、以下のようにエラーになります。

Installing PHP SAPI module:       apache2handler
/usr/share/apache2/build/instdso.sh SH_LIBTOOL='/usr/share/apr-1.0/build/libtool' libphp5.la /usr/lib/apache2/modules
/usr/share/apr-1.0/build/libtool --mode=install cp libphp5.la /usr/lib/apache2/modules/
libtool: install: cp .libs/libphp5.so /usr/lib/apache2/modules/libphp5.so
libtool: install: cp .libs/libphp5.lai /usr/lib/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /usr/local/lib/php-5.3.2/libs'
chmod 644 /usr/lib/apache2/modules/libphp5.so
apxs:Error: Activation failed for custom /etc/apache2/httpd.conf file..
apxs:Error: At least one `LoadModule' directive already has to exist..
make: *** [install-sapi] エラー 1

以下のようにhttpd.confを編集し、保存します。
# nano /etc/apache2/httpd.conf

#dummy
LoadModule hoge hoge.so

再度 # make install を実行

Installing PHP SAPI module:       apache2handler
/usr/share/apache2/build/instdso.sh SH_LIBTOOL='/usr/share/apr-1.0/build/libtool' libphp5.la /usr/lib/apache2/modules
/usr/share/apr-1.0/build/libtool --mode=install cp libphp5.la /usr/lib/apache2/modules/
libtool: install: cp .libs/libphp5.so /usr/lib/apache2/modules/libphp5.so
libtool: install: cp .libs/libphp5.lai /usr/lib/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /usr/local/lib/php-5.3.2/libs'
chmod 644 /usr/lib/apache2/modules/libphp5.so
[activating module `php5' in /etc/apache2/httpd.conf]
Installing PHP CLI binary:        /usr/local/lib/php-5.3.2/bin/
Installing PHP CLI man page:      /usr/local/lib/php-5.3.2/man/man1/
Installing build environment:     /usr/local/lib/php-5.3.2/lib/php/build/
Installing header files:          /usr/local/lib/php-5.3.2/include/php/
Installing helper programs:       /usr/local/lib/php-5.3.2/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/lib/php-5.3.2/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/lib/php-5.3.2/
[PEAR] Archive_Tar    - installed: 1.3.3
[PEAR] Console_Getopt - installed: 1.2.3
[PEAR] Structures_Graph- installed: 1.0.2
[PEAR] XML_Util       - installed: 1.2.1
[PEAR] PEAR           - installed: 1.9.0
Wrote PEAR system config file at: /usr/local/lib/php-5.3.2/etc/pear.conf
You may want to add: /usr/local/lib/php-5.3.2 to your php.ini include_path
/usr/local/lib/php-5.3.2/build/shtool install -c ext/phar/phar.phar /usr/local/lib/php-5.3.2/bin
ln -s -f /usr/local/lib/php-5.3.2/bin/phar.phar /usr/local/lib/php-5.3.2/bin/phar
Installing PDO headers:          /usr/local/lib/php-5.3.2/include/php/ext/pdo/

次に、
# nano /etc/apache2/httpd.conf 
で以下のように、全行をコメントアウトし、保存します。

#dummy
#LoadModule hoge hoge.so
#LoadModule php5_module        /usr/lib/apache2/modules/libphp5.so

apache2を再起動します。
# /etc/init.d/apache2 restart

phpinfo() で確認すると、
PHP Version 5.3.2 となりました。

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

www.hbirds.net