php 配置远程调试,PHP Linux 环境下搭建 XDEBUG并配置远程调试

在网站 https://xdebug.org/download.php 找到对应PHP版本的XDEBUG下载,下载时选择source版本

e7e07231254c

image

获取下载地址## 下载打包的源码

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

解包

tar zxvf xdebug-2.5.5.tgz

进入解包后的源码目录

cd xdebug-2.5.5

执行 phpize 生成配置文件脚本 configure

phpize

查找php-config 的位置

find / -name php-config

执行 configure 脚本 --with-php-config=php-config的路径

./configure --with-php-config=/usr/local/php/bin/php-config

编译源码

make

编译生成PHP的扩展模块,成功完成后根据提示( Installing shared extensions: )找到模块路径记录下来后面要用来配置xdebug

make install

e7e07231254c

image

服务器端安装完成

配置PHPSTORM 连接上服务器,相当于 ftp

e7e07231254c

image

e7e07231254c

image

e7e07231254c

image

e7e07231254c

image

e7e07231254c

image

e7e07231254c

image

e7e07231254c

image

配置PHPSTORM XDEBUG端口

e7e07231254c

image

e7e07231254c

image

e7e07231254c

image

e7e07231254c

image

配置Xdebug 和 Xdebug 与 PHPSTORM 的通信

查看PHP载入的所有配置文件

e7e07231254c

image

进入PHP会扫描的配置文件夹,添加xdebug的配置,这里要注意可能只是命令行的配置文件,不代表 php-fpm 也会使用这些配置,如果后面没有在 phpinfo 中看到xdebug, 先重启 php-fpm 和 nginx,如果还是无效那么要去 php-fpm 读取的配置中设置 xdebug 的配置

; so 的路径 make install 成功后有提示,上面讲过

zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so

xdebug.remote_enable=1

;远程IP(公网IP),由于公网IP是动态的,

;但是没有路由器权限,又不能做端口映射

;所以这里采用 SSH 隧道的方式转发

xdebug.remote_host=127.0.0.1

;远程调试端口

xdebug.remote_port=9020

;调试器的关键字

xdebug.idekey=PHPSTORM

xdebug.remote_handler=dbgp

xdebug.remote_mode=req

xdebug.remote_log=/var/log/php/xdebug.log

xdebug.remote_timeout=20000

重启 php-fpm 和 nginx

systemctl restart php-fpm

systemctl restart nginx

建立后台运行的SSH隧道

ssh -f -N -R 192.168.1.197:9020:127.0.0.1:9020 root@110.110.110.128

完成。。。。

XDEBUG 调试示例

e7e07231254c

image

e7e07231254c

image

e7e07231254c

image

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值