xdebug安装使用-mac

2018-04-23 10:23:45

1.安装xdebug

1) 下载源码

> git clone git://github.com/xdebug/xdebug.git

2) 进入目录

> cd xdebug

3) 编译

> ./rebuild.sh

这一步对应的操作分别如下:

> phpize
> ./configure --enable-xdebug
> make clean
> make
> make install

执行成功后会在./xdebug/modules下生成xdebug.so扩展

4) 复制xdebug.so到扩展路径下

> cp ./xdebug/modules/xdebug.so /xx/xdebug/

5) 添加扩展

php conf.d 下加ext-xdebug.ini文件,内容如下:

[xdebug]
zend_extension="/xx/xdebug/xdebug.so"

6) 重启php-fpm

pgrep php-fpm |xargs sudo kill -USR2

2.使用xdebug

配置php.ini,添加如下内容可启用性能监控

[xdebug]
zend_extension="/usr/local/opt/xdebug/xdebug.so"
xdebug.profiler_enable = on
xdebug.auto_trace = on
xdebug.trace_output_dir = /tmp/xdebuglog
xdebug.trace_output_name = trace.%c
xdebug.profiler_output_dir = /tmp/xdebuglog