我需要调试位于远程服务器上Docker容器内的PHP脚本。
通常,我在Windows中使用Visual Studio Code调试我的代码。我一直在调试我的开发代码(位于Vagrant中),没有任何问题。
但是当谈到在远程服务器上的Docker中调试文件时,我无法让它工作。
这是我在php.ini上的xdebug设置(位于远程服务器上的docker中)
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host=172.18.0.1
xdebug.remote_port=9000
xdebug.remote_log=/tmp/debug.log
上面设置中的remote_host
IP地址是从Docker内部看到的远程主机的IP。
我尝试过ssh-tunneling到我的远程服务器(从Windows,使用telnet)。
但是当我尝试在浏览器上运行该网站时,我的Visual Studio代码无法检测到调试会话。
基本上我所做的就是这些:
ssh -R 9000:localhost:9000 username@myremoteserver.com
/sbin/ip route|awk '/default/ { print $3 }'
当我运行网站时,/tmp/debug.log
包含以下内容:
I: Connecting to configured address/port: 172.18.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///magento/test.php" language="PHP" xdebug:language_version="5.6.33-1+ubuntu16.04.1+deb.sury.org+1" protocol_version="1.0" appid="12776" idekey="www-data"><engine version="2.5.5"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2017 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
我怎样才能传递&#39; Xdebug从Docker,到我的远程服务器,到我本地电脑上的IDE的连接?
答案 0 :(得分:1)
通过ssh-tunnel:(
但是ngrok是可能的。您应该:
ngrok
; ngrok tcp 9000
; xdebug.remote_port
的信息设置xdebug.remote_host
和ngrok
。