linux 安装xdebug

一、安装了 xdebug

php -m  | grep 'xdebug'

 如果没有安装就执行

首先根据 phpinfo() 信息 下载对应的版本,具体看参数:

下载地址:https://xdebug.org/download 

 

把phpinfo()的打印信息 复制到 https://xdebug.org/wizard 下,可以得到安装信息

 

-1.下载xdebug
wget https://xdebug.org/files/xdebug-2.7.0.tgz

-2.解压
tar -zxvf xdebug-2.7.0.tgz
cd xdebug-2.7.0

-3.运行phpize,通过phpize可以 生成 configure 文件,动态的添加php扩展
phpize 或者 /usr/bin/phpize7.2

-4. 配置,--with-php-config=/你php的bin路径/php-config
./configure --enable-xdebug --with-php-config=/usr/bin/php-config7.2

-5.编译&生成
make && make install

编译&&生成后,屏幕上会有输出

installing shared extensions:     /usr/lib/php/20170718/

+----------------------------------------------------------------------+
| |
| INSTALLATION INSTRUCTIONS |
| ========================= |
| |
| See http://xdebug.org/install.php#configure-php for instructions |
| on how to enable Xdebug for PHP. |
| |
| Documentation is available online as well: |
| - 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 |
| |
| |
| NOTE: Please disregard the message |
| You should add "extension=xdebug.so" to php.ini |
| that is emitted by the PECL installer. This does not work for |
| Xdebug. |
| |
+----------------------------------------------------------------------+

编译安装完成后会有一个 modules文件夹,该文件夹下有一个xdebug.so的文件,将此文件复制到对应PHP版本的扩展目录即可。当然,如果PHP已经设置了扩展目录地址,该文件就会自动复制到了扩展目录中,

如:我的扩展目录是  /usr/lib/php/20170718/ ,目录下面会生成一个 xdebug.so 的动态库文件

说明:  /usr/lib/php/20170718/ 该目录是存放PHP扩展的目录,phpinfo()里看到 extension_dir 该属性的值。

二、PHP 配置文件添加配置

vim /usr/local/php/etc/php.ini
 
- 添加
zend_extension=xdebug.so # 这里没有写绝对路径,是因为会到扩展目录中去找
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9900
xdebug.max_nesting_level = 512

- 保存退出

 

三、重启PHP

service php-fpm restart

 

四、查看

通过 phpinfo() 输出查看,或者 通过命令 php -m | grep 'xdebug'

 

注意事项

  • 如果配置时出现"configure: error: Cannot find PHP-config. Please use --with-PHP-config=PATH"错误,增加" --with-php-config=/usr/local/php/bin/php-config" 配置项
  • 如果报版本错误,安装对应的版本



posted on 2019-12-23 15:50  追风的浪子  阅读(274)  评论(0编辑  收藏  举报

导航