Heim  >  Artikel  >  Backend-Entwicklung  >  php xdebug的编译安装以及配置说明

php xdebug的编译安装以及配置说明

WBOY
WBOYOriginal
2016-08-08 09:32:161081Durchsuche

今天有个PHP小生问我php 的Xdebug扩展的问题,于是就又重新写了这篇笔记,其实这个安装配置很简单,考虑到新手的理解,配备图文较为详细和实际模拟操作步骤,大牛略过即可

首先打开linux终端执行命令 git clone git://github.com/xdebug/xdebug.git 下载xdebug扩展包,如下图: (没有git的请先安装git)


然后执行如下命令切换到xdebug文件包目录
[Happy@localhost www]$ cd xdebug
在xdebug目录下执行phpize命令(具体替换成您的实际PHP安装路径下的phpize文件所在路径)
[Happy@localhost xdebug]$ /usr/local/php/bin/phpize   (执行结果如下图可看到php的版本日期等)

编译xdebug扩展包
[Happy@localhost xdebug]$ ./configure --with-php-config=/usr/local/php/bin/php-config 
[Happy@localhost xdebug]$ make  (如图所示出现如下信息则说明make成功)

然后执行最后一步make install完成安装
[Happy@localhost xdebug]$ make install
出现如图所示表示安装成功并显示出php扩展所在目录位置

此时查看扩展目录即可看到xdebug.so扩展文件已经安装到PHP扩展目录下

配置PHP.INI 文件 加入XDEBUG扩展
[Xdebug]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
xdebug.remote_enable        = true
xdebug.remote_host          = localhost
#default port 9000
#xdebug.remote_port         = 9000
xdebug.profiler_enable      = on
xdebug.trace_output_dir     = "/var/www/phpxdebug"
xdebug.profiler_output_dir  = "/var/www/phpxdebug"
xdebug.auto_trace           = On
xdebug.show_exception_trace = On
xdebug.remote_autostart     = On
xdebug.collect_vars         = On
xdebug.collect_return       = On
xdebug.remote_handler       =dbgp
xdebug.max_nesting_level = 10000
php.ini配置参数修改完成后在PHP页面中调用phpinfo()函数可看到页面中Xdebug的扩展信息和相关参数选项,我这里的设置如图所示:

php xdebug 参数说明(更多问题请参见 摘取天上星 之前关于xdebug的日志)

zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so" #加载扩展文件 xdebug.remote_enable = true xdebug.remote_host = localhost #xdebug.remote_port = 9000 #默认端口 9000 xdebug.profiler_enable = on xdebug.trace_output_dir = "/var/www/phpxdebug" xdebug.profiler_output_dir = "/var/www/phpxdebug" #其余参数 #开启自动跟踪 xdebug.auto_trace = On #开启异常跟踪 xdebug.show_exception_trace = On #开启远程调试自动启动 xdebug.remote_autostart = On #收集变量 xdebug.collect_vars = On #收集返回值 xdebug.collect_return = On #用于zend studio远程调试的应用层通信协议 xdebug.remote_handler =dbgp #如果设得太小,函数中有递归调用自身次数太多时会报超过最大嵌套数错 xdebug.max_nesting_level = 10000 zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"Xdebug加载方法,不同系统及 PHP 版本有不同写法Linux 和 Mac OS X : zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
Windows Thread-Safe 版 PHP : zend_extension_ts = "D:\php\ext\xdebug.dll"Windows Non-Thread-Safe 版 PHP : zend_extension = "D:\php\ext\xdebug.dll"所以同一服务器只能加载一个调试工具,要么 Zend Debugger 要么 Xdebug但在 PHP5.5 环境下测试, Thread-Safe 版 PHP 后面不能加 _ts 只能写成 zend_extension = xdebug.remote_enable = true 允许远程IDE调试xdebug.profiler_enable = on 及后面的目录 "/var/www/phpxdebug" 作用是开启把执行情况的分析文件写入到指定目录中的功能,可自由设置。也可不写生成的文件,例如 cachegrind.out.4408 这种格式命名的文件,用编辑器打开可以看到很多程序运行的相关细节信息

以上就介绍了php xdebug的编译安装以及配置说明,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn