Xdebug(2.0.5)をインストールする

環境
CentOS:5.4
PHP:5.3.1
・(php-develインストール済)

LatestバージョンをGET〜解凍〜phpize

$ wget http://xdebug.org/files/xdebug-2.0.5.tgz
$ tar zxvf xdebug-2.0.5.tgz
$ cd xdebug-2.0.5
$ phpize

ここでエラー発生。

Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
/usr/bin/m4: unrecognized option `--debugfile=autom4te.cache/traces.0t'
Try `/usr/bin/m4 --help' for more information.
autom4te: /usr/bin/m4 failed with exit status: 1

どうやら、m4関連のオプションが認識されていないらしいので、m4とautoconfをlatestバージョンにアップデートすればいいのかなと思いインストール作業へ。ここで注意、autoconfはm4に依存するらしいので、m4からインストールする。

m4(1.4.13)インストール

$ wget ftp://ftp.gnu.org/gnu/m4/m4-1.4.10.tar.gz
$ tar zxvf m4-1.4.10.tar.gz
$ cd m4-1.4.10
$ ./configure --prefix=/usr/local/
$ make
$ make install

autoconf(2.65)インストール

$ wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.65.tar.xz
$ tar zxvf autoconf-2.65.tar.xz
$ cd autoconf-2.65
$ ./configure --prefix=/usr/local/
$ make
$ make install

でそれぞれ確認

$ /usr/local/bin/m4 --version
m4 (GNU M4) 1.4.13
・・・・・・
$ /usr/local/bin/autoconf --version
autoconf (GNU Autoconf) 2.65
・・・・・・

ちゃんと、入ってました。

さてここで、本題に戻ってphpizeの作業に戻る。

$ phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
/usr/bin/m4: unrecognized option `--debugfile=autom4te.cache/traces.0t'
Try `/usr/bin/m4 --help' for more information.
autom4te: /usr/bin/m4 failed with exit status: 1

またしても同じエラー。???と思ってエラーを確認すると、インストールした、m4のディレクトリ/usr/local/binではなく、前のバージョンの/usr/bin/m4が用いられてることに気付いた。
なので、/usr/bin/の旧バージョンを上書きしてみることに。(一応バックアップ推奨)。読み込むパスの優先度の設定をすればいいと思うが、やり方がわからなかったので、力技でやってみた。(autoconfをインスールした際にできた、その他のコマンドも上書きした。)

$ rm -f /usr/bin/m4
$ cp /usr/local/bin/m4 /usr/bin/.

$ rm /usr/bin/autoconf
$ cp /usr/local/bin/autoconf /usr/bin/.

$ rm -f /usr/bin/autoheader
$ cp /usr/local/bin/autoheader /usr/bin/.

$ rm -f /usr/bin/autom4te
$ cp /usr/local/bin/autom4te /usr/bin/.

$ rm -f /usr/bin/autoscan
$ cp /usr/local/bin/autoscan /usr/bin/.

$ rm -f /usr/bin/autoreconf
$ cp /usr/local/bin/autoreconf /usr/bin/.

$ rm -f /usr/bin/autoupdate
$ cp /usr/local/bin/autoupdate /usr/bin/.

$ rm -f /usr/bin/ifnames
$ cp /usr/local/bin/ifnames /usr/bin/.

これで、もう一度。phpsizeをすると通ったので、その後の処理もしてしまう。

$ phpize
$ ./configure --enable-xdebug
$ make
$ cp modules/xdebug.so /usr/lib/php/modules/.

これで、Xdebugのインストールは終了。最後にphp.iniに以下を追加して再読み込みして終了。

$ vim php.ini
・・・・・・
zend_extension=/usr/lib/php/modules/xdebug.so
$ /etc/rc.d/init.d/httpd reload

phpファイルを作って、var_dump()やエラー画面が綺麗に表示されていれば無事終了。


xdebugの設定についてはここを参考に。


参考