安装过程如下:
1、下载XDebug源码:http://xdebug.org/files/xdebug-2.3.3.tgz
2、解压到某个目录,如 /opt/software/xdebug-2.3.3
tar -xzvf ./xdebug-2.3.3.tgz
3、运行 phpize 命令
cd /opt/software/xdebug-2.3.3 /opt/software/php/bin/phpize
但是,报错了:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
4、安装 autoconf
sudo apt-get install autoconf
5、重新运行 phpize 命令
wenjianbao@wenjianbao-pc:/opt/software/xdebug-2.3.3$ /opt/software/php/bin/phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525
注意:一定要切换到xdebug源码目录去运行phpize命令!
6、编译安装XDebug
./configure --enable-xdebug --with-php-config=/opt/software/php/bin/php-config make && make install
7、配置 php.ini,追加以下内容:
[XDebug]
zend_extension = "/opt/software/php/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/opt/software/tmp/xdebug"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9001
xdebug.trace_output_dir = "/opt/software/tmp/xdebug"
8、设置 PhpStorm 的 XDebug 调试端口为 9001
File -> Default Settings -> Languages & Frameworks -> PHP -> Debug -> xdebug -> Debug port 设置为 9001
注意:端口9000已被php-fpm占用
9、调试PHP,参考先前的文章: