centos 下安装xdebug以便netbeans调试PHP

本文详细介绍了如何通过源码安装Xdebug的过程,并解决了在安装过程中遇到的问题,如缺少phpize工具等。此外,还提供了如何配置Xdebug以便于在NetBeans中进行PHP调试的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

xdebug官方网站没有.tar.gz的文件,只有源码,那就只能源码安装了,下载源码之后

得到的文件夹里readme有这样一段话

You need to compile Xdebug separately from the rest of PHP.  Note, however,
that you need access to the scripts "phpize" and "php-config".  If your
system does not have "phpize" and "php-config", you will need to compile
and install PHP from a source tarball first, as these script are
by-products of the PHP compilation and installation processes. It is
important that the source version matches the installed version as there
are slight, but important, differences between PHP versions.

Once you have access to "phpize" and "php-config", do the following:

看来还必须源码安装php,从而得到phpize(扩展php模块用的工具)

下载php源码,解压缩.configure 的时候出现

./configure --prefix=/usr/local/php --with-apxs=/usr/local/apache --with-mysql
configure: error: xml2-config not found. Please check your libxml2 installation.

yum search xml2 并安装之,之后make&&make install

安装完毕进入xdebug目录执行folder/phpize

出现

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

yum search autoconf

yum install之

之后在xdebug目录下phpize

之后 ./configure --enable-xdebug

make&& make install

安装完毕

在/usr/local/lib64/extensions/no-debug-non-zts-20090626下出现了一个xdebug.so

这个就是我想要的

之后,php就支持了xdebug

配置完成之后,往往会出现netbeans无法连接到xdebug的情况,我的php.ini 关于xdebug的配置如下

zend_extension ="/usr/local/lib64/extensions/no-debug-non-zts-20090626/xdebug.so"
[Xdebug]
xdebug.profiler_enable=off
xdebug.profiler_enable_trigger = off
xdebug.trace_output_dir="/usr/local/php5/xdebug/"
xdebug.profiler_output_dir="/usr/local/php5/xdebug/"
xdebug.remote_enable=on       
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

这里注意端口,是9000,要和netbeans的php设置中的调试界面中的端口设置要一样,另外phpinfo()之后,可以看到有个IDE Key,这个和netbeans中php中调试中的会话ID一致,我的netbeans连接不上xdebug是因为我的端口号设错了,一般来说,完成这些步骤,应该就可以在netbeans中调试PHP了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值