我需要调试位于远程服务器上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隧道传输到我的远程服务器(从Windows,使用telnet)。
但是,当我尝试在浏览器上运行该站点时,我的Visual Studio代码无法检测到调试会话。
基本上我所做的是这些:
ssh -R 9000:localhost:9000 [email protected]
创建到远程服务器的ssh隧道(将服务器上的端口9000转发到本地主机:9000)>/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>
如何将Xdebug设置的连接从Docker'中继'到我的远程服务器,再到本地PC上的IDE?”>
我需要调试位于远程服务器上Docker容器内的PHP脚本。通常,我在Windows中使用Visual Studio Code调试代码。我一直在调试我的开发人员代码(位于...
我没有成功通过ssh-tunnel:(
做同样的事情但是ngrok有可能。您应该: