ubuntu 安装php xdebug

一.下载

下载与PHP版兼容的Xdebug扩展,并将其保存在php /文件夹中。

php /文件夹 的位置是在PHP引擎安装期间定义的。

如果您使用的是AMP软件包,则可能已安装Xdebug扩展。按照xdebug.txt中的说明进行操作

二. 将Xdebug与PHP解释器集成 在php.in加入

[XDebug]
zend_extension="php_xdebug.dll"
xdebug.idekey = PHPSTORM
xdebug.show_error_trace = 1
;指定Xdebug扩展文件的绝对路径
;启用性能检测分析  
xdebug.profiler_enable=On
;启用代码自动跟踪  
xdebug.auto_trace=on
;允许收集传递给函数的参数变量  
xdebug.collect_params=On
;允许收集函数调用的返回值  
xdebug.collect_return=On
;指定堆栈跟踪文件的存放目录 
xdebug.trace_output_dir="C:\phpStudy\PHPTutorial\tmp\xdebug"
xdebug.profiler_output_dir="C:\phpStudy\PHPTutorial\tmp\xdebug"
xdebug.remote_enable = On
xdebug.remote_port=9000
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.var_display_max_depth = 10

liunux安装php xdebug

http://xdebug.org/install.php#configure-php 
A list of all settings:  http://xdebug.org/docs-settings.php     
A list of all functions: http://xdebug.org/docs-functions.php    
Profiling instructions:  http://xdebug.org/docs-profiling2.php   
Remote debugging:        http://xdebug.org/docs-debugger.php  

一、下载并编译 xdebug

下载 xdebug 最新的源码包

wget https://xdebug.org/files/xdebug-2.6.0.tgz

解压缩

tar -zxvf xdebug-2.6.0.tgz

编译安装

cd xdebug-2.6.0
phpize
./configure  --enable-xdebug 
make
make install

三、配置

  • /etc/php/7.2/mods-available/xdebug.ini加入

  • zend_extension=xdebug.so
    extension=xdebug.so
    xdebug.remote_enable = 1
    xdebug.remote_port = 9000
    xdebug.idekey = PHPSTORM
    xdebug.show_error_trace = 1
    xdebug.remote_autostart = 1
    xdebug.file_link_format = phpstorm://open?%f:%l
  • 在php.ini中增加xdebug配置 xdebug.so路径 在安装完xdebug时控制台会有提示

zend_extension="php_xdebug.dll"

xdebug.idekey = PHPSTORM

xdebug.remote_enable = On

xdebug.remote_port=9000

xdebug.remote_handler = dbgp

xdebug.remote_host = localhost

xdebug.var_display_max_depth = 10

  • 增加软连接 //一下配置我并没有使用
cd /etc/php/7.2/fpm/conf.d/
sudo ln -s /etc/php/7.2/mods-available/xdebug.ini 20-xdebug.ini
cd /etc/php/7.2/cli/conf.d/
sudo ln -s /etc/php/7.2/mods-available/xdebug.ini 20-xdebug.ini

重启apache,检测是否安装成功:

$ sudo apachectl restart
$ php -m | grep xdebug

四、测试

  1. cli 环境下,查看 php -m
  2. 测试 phpinfo,查看 xdebug 的信息 (略)
  3. phpstorm 测试 xdebug