源码安装 xdebug,并在 vscode 中配置

从源码安装 Xdebug

下载解压

Xdebug 官方下载地址

https://xdebug.org/download

下载最新版本源码,并解压

[root@localhost ~]# wget https://xdebug.org/files/xdebug-2.9.0.tgz
[root@localhost ~]# tar xzvf xdebug-2.9.0.tgz
[root@localhost ~]# cd xdebug-2.9.0

编译安装

phpize 配置 xdebug 源码

[root@localhost xdebug-2.9.0]# phpize
[root@localhost xdebug-2.9.0]# ./configure 
[root@localhost xdebug-2.9.0]# make && make install

php.ini 中加入以下配置

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9000
xdebug.remote_connect_back=1
xdebug.auto_trace=1
xdebug.remote_log=/tmp/xdebug.log

重启 php-fpm 完成安装,命令行输入 php -v 可以看到

PHP 7.3.10 (cli) (built: Oct  7 2019 13:52:56) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.10, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.9.0, Copyright (c) 2002-2019, by Derick Rethans
    with Zend OPcache v7.3.10, Copyright (c) 1999-2018, by Zend Technologies

其中有 with Xdebug v2.9.0, Copyright (c) 2002-2019, by Derick Rethans 说明 xdebug 安装完成

配置 vscode

安装 vscode 相关插件

安装 PHP Debug 插件,创建如下配置文件

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "pathMappings": {
                "/data/wwwroot/test": "${workspaceRoot}",
            },
            "port": 9000
        }
    ]
}

其中 /data/wwwroot/test 是对应的远程目录

开调试

打开 vscode 中的 PHP Debug 插件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值