从源码安装 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 Debu