LY’Blog~~blog.ly5.org~~ Rotating Header Image

Apache2.0.63下安装Xdebug调试PHP4.4.9

在上次安装完FreeBSD+Apache+PHP的环境后,在上面跑一个PHP的系统感觉非常慢,于是想装一个Xdebug来调试希望能找出问题的所在,以下是我的安装过程中间也碰到了一些问题。

[安装配置]
1、要在FreeBSD下安装Xdebug得通过源代码包进行编译安装,首先去http://www.xdebug.org官方网站下载源代码包,我下载的[2008-04-09]Source: xdebug 2.0.3(这个版本在编译过程中会出错,下面详细讲解)。

2、开始编译Xdebug

# tar -xvf xdebug-2.0.3.tgz
# cd xdebug-2.0.3
# phpize
# ./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config
# make
/bin/sh /usr/home/ly/xdebug-2.0.3/libtool --mode=compile gcc  -I. -I/usr/home/ly/xdebug-2.0.3 -DPHP_ATOM_INC -I/usr/home/ly/xdebug-2.0.3/include -I/usr/home/ly/xdebug-2.0.3/main -I/usr/home/ly/xdebug-2.0.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend  -DHAVE_CONFIG_H  -g -O0   -c /usr/home/ly/xdebug-2.0.3/xdebug.c -o xdebug.lo
gcc -I. -I/usr/home/ly/xdebug-2.0.3 -DPHP_ATOM_INC -I/usr/home/ly/xdebug-2.0.3/include -I/usr/home/ly/xdebug-2.0.3/main -I/usr/home/ly/xdebug-2.0.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -DHAVE_CONFIG_H -g -O0 -c /usr/home/ly/xdebug-2.0.3/xdebug.c         -fPIC -DPIC -o xdebug.lo
/usr/home/ly/xdebug-2.0.3/xdebug.c:172: warning: initialization makes integer from pointer without a cast
/bin/sh /usr/home/ly/xdebug-2.0.3/libtool --mode=compile gcc  -I. -I/usr/home/ly/xdebug-2.0.3 -DPHP_ATOM_INC -I/usr/home/ly/xdebug-2.0.3/include -I/usr/home/ly/xdebug-2.0.3/main -I/usr/home/ly/xdebug-2.0.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend  -DHAVE_CONFIG_H  -g -O0   -c /usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c -o xdebug_code_coverage.lo
gcc -I. -I/usr/home/ly/xdebug-2.0.3 -DPHP_ATOM_INC -I/usr/home/ly/xdebug-2.0.3/include -I/usr/home/ly/xdebug-2.0.3/main -I/usr/home/ly/xdebug-2.0.3 -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -DHAVE_CONFIG_H -g -O0 -c /usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c         -fPIC -DPIC -o xdebug_code_coverage.lo
/usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c: In function 'xdebug_find_jump':
/usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c:148: error: 'union ' has no member named 'jmp_addr'/usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c: In function 'prefill_from_oparray':/usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c:233: warning: assignment makes pointer from integer without a cast/usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c: In function 'prefill_from_function_table':/usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c:272: warning: comparison between pointer and integer/usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c: In function 'xdebug_prefill_code_coverage':/usr/home/ly/xdebug-2.0.3/xdebug_code_coverage.c:312: warning: comparison between pointer and integer*** Error code 1

Stop in /usr/home/ly/xdebug-2.0.3.

注:在扫行make命令后突然报错禁止了编译google了半天无法找到相关解决办法,在官方的bugs上也找到了一样的报错信息但无人解答是否原因和解决办法,于是试想装一下xdebug-2.0.2看是否也报同样的错误,在官方网站下载xdebug-2.0.2的源代码包开始编译,到执行make命令这里时期持着不报错,果然没有让我失望顺利通过make,然后接着下面的编译。
http://www.xdebug.org/archives/xdebug-dev/1427.html
http://inhalt.serviert.de/wissen/gpl/php/php5-xdebug-debugger-profiler-development-tool-unter-debian-etch-und-apache2
贴上我找的相关资料。 

3.接着make命令往下编译

# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20020429/
# cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20020429/libxdebug.so.0.0 /usr/local/php/lib/php/extensions/xdebug.so

注:phpize是用来生成 configure 文件,当你安装PHP的时候指定了--prefix参数时phpize会报错应该加上你安装PHP的路经如:/usr/local/php/bin/phpize。而红色部分则为PHP的安装路经,安装成功就成生/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429/libxdebug.so.0.0文件,/usr/local/php/lib/php/extensions/no-debug-non-zts-20020429这个路经试PHP的版本不同也会不同。 

3.修改php.ini配置Xdebug

# vi /usr/local/php/lib/php.ini
[Xdebug]
extension = "/usr/local/php/lib/php/extensions/xdebug.so"
xdebug.auto_trace = on
xdebug.auto_profile = on
xdebug.collect_params = on
xdebug.collect_return = on
xdebug.profiler_enable = on
xdebug.trace_output_dir = "/tmp/xdebug"
xdebug.profiler_output_dir = "/tmp/xdebug"

xdebug.dump.GET = *
xdebug.dump.POST = *
xdebug.dump.COOKIE = *
xdebug.dump.SESSION = *

xdebug.var_display_max_data = 4056
xdebug.var_display_max_depth = 5

注:修改php.ini,去除Zend的配置信息,增加以上配置信息支持XDebug扩展

4.重启Apache完成安装

# mkdir -p /tmp/xdebug
# chmod 755 /tmp/xdebug
# /usr/local/apache2/bin/apachectl start

参考的相关资料:
http://www.xdebug.org/docs/install
http://blog.s135.com/read.php/257.htm
http://hi.baidu.com/leakon/blog/item/1e4c024f741bc934aec3ab72.html

0 Comments on “Apache2.0.63下安装Xdebug调试PHP4.4.9”

Leave a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word