Linux安装php-xdebug扩展

  1. 下载xdebug
    url:https://xdebug.org/download.php
  2. 解压、安装
    tar -zxvf xdebug-2.4.0.tgz
    phpize
    ./configure
    make
    make install
  3. 修改配置文件
    sudo mkdir /usr/local/lib/php5-ext
    sudo mv /tmp/xdebug-2.5.5/modules/xdebug.so /usr/local/lib/php5-ext/
    php5-fpm -i | grep php.ini
    sudo vim /etc/php5/fpm/php.ini
    在文件末尾加入
    [xdebug]
    zend_extension="/usr/local/lib/php5-ext/xdebug.so"
    ps:xdebug常用配置项说明,https://xdebug.org/docs/all_settings#auto_trace
  4. php5-fpm -i | grep xdebug 查看是否成功
  5. 在php文件中使用xdebug调试
$a = 'hello';  
xdebug_debug_zval('a');  

访问url:http://test.phpdev/test.php

a:
(refcount=1, is_ref=0),string 'hello' (length=5)

todo

xdebug具体调试用例

附:github上的安装步骤
https://github.com/xdebug/xdebug

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

Unpack the tarball: tar -xzf xdebug-2.4.x.tgz. Note that you do not need to unpack the tarball inside the PHP source code tree. Xdebug is compiled separately, all by itself, as stated above.
cd xdebug-2.4.x
Run phpize: phpize (or /path/to/phpize if phpize is not in your path).
./configure --enable-xdebug (or: ../configure --enable-xdebug --with-php-config=/path/to/php-config if php-config is not in your path)
Run: make
cp modules/xdebug.so /to/wherever/you/want/it
add the following line to php.ini: zend_extension="/wherever/you/put/it/xdebug.so"
Restart your webserver.
Write a PHP page that calls phpinfo();. Load it in a browser and look for the info on the xdebug module. If you see it, you have been successful!

你可能感兴趣的:(Linux安装php-xdebug扩展)