无法使用带有EC2的PhpStorm进行调试

无法使用带有EC2的PhpStorm进行调试,php,amazon-ec2,phpstorm,remote-debugging,Php,Amazon Ec2,Phpstorm,Remote Debugging,我试图在本地机器上配置PhpStorm,存储库位于AmazonEC2上。我也使用了SSH隧道,但无法使用远程调试器进行调试 以下是我的配置文件,我已将相同的配置放在其中 /etc/php-5.6.d/xdebug.ini /etc/php.ini zend_extension=/usr/lib64/php/5.6/modules/xdebug.so xdebug.remote_enable=1 ; Enable xdebug xdebug.remote_auto

我试图在本地机器上配置PhpStorm,存储库位于AmazonEC2上。我也使用了SSH隧道,但无法使用远程调试器进行调试

以下是我的配置文件,我已将相同的配置放在其中

/etc/php-5.6.d/xdebug.ini
/etc/php.ini

zend_extension=/usr/lib64/php/5.6/modules/xdebug.so
xdebug.remote_enable=1                 ; Enable xdebug
xdebug.remote_autostart=Off             ; Only start xdebug on demand, not on every request
xdebug.remote_host=127.0.0.1      ; This is unused if the next setting is 'On'
;xdebug.remote_connect_back=On           ; Use a special $_SERVER['...'] variable to get the remote address
xdebug.remote_port=9002                 ; Port on the IDE to connect back to. Usually it is 9000
xdebug.idekey="phpstorm"                ; The IDE key which should match the XDEBUG_SESSION cookie valu
xdebug.remote_connect_back=1
xdebug.remote_log="/tmp/xdebug_remote_log.log"
xdebug.extended_info=1e

我使用下面给出的命令创建SSH隧道

ssh -R 9002:localhost:9002 root@18.2xx.2xx.1xx
关闭远程连接后,新日志将显示在此处

Log opened at 2018-04-23 15:59:32
I: Connecting to configured address/port: 127.0.0.1:9002.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/immunedata-prod/immunedata/website-php/index.php" language="PHP" xdebug:language_version="5.6.32" protocol_version="1.0" appid="15683" idekey="PHPSTORM"><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>

Log closed at 2018-04-23 15:59:32
日志于2018-04-23 15:59:32打开
I:连接到配置的地址/端口:127.0.0.1:9002。
I:已连接到客户端。:-)
-> 
-> 
日志于2018-04-23 15:59:32关闭

如何解决这个问题,我没有使用端口9000,因为在该端口上运行着另一个微服务。

1)在一个地方,您正在声明9002,在另一个地方--9000(主要是xdebug日志和您的设置的差异)。2) 如果您使用SSH隧道。。您最好连接到127.0.0.1。使用
xdebug.remote\u connect\u back=1
忽略
xdebug.remote\u host
的值(这是xdebug日志确认的)3)隧道用于9000。。但IDE正在收听9002。。。总的来说:仔细检查您的设置以及在何处使用了哪些值--按照第一条评论中的文章进行操作,并在两处使用一致的值(这样就不太可能出错)。@LazyOne谢谢,我在这里发布了错误的ssh命令我正在使用端口9002进行隧道传输,我认为日志发布了旧的日志,我将检查这些,并将更新question@LazyOne我已经更新了日志,您可以看到所有设置现在都指向端口9002Re check#2。您正在使用SSH隧道。。所以在你的远程服务器上。。。您需要连接到他们的本地端口,以便它通过隧道返回到您的本地PC。根据xdebug日志,xdebug尝试连接到
192.147.26.229:9002
。。而它应该是
127.0.0.1:9002
(除非它们都指向同一个服务器)。您有
xdebug.remote\u connect\u back=1
——使用此选项,将忽略
xdebug.remote\u host=127.0.0.1
设置。所以将该选项设置为
Off/0
,然后重试。