简体   繁体   English

XDebug with PhpStorm:调试CLI脚本,通过反向SSH隧道进行连接

[英]XDebug with PhpStorm: Debugging a CLI script, connection over reverse SSH tunnel

I've got the PhpStorm 10.0.3 and trying to debug a CLI script that runs on a remote server. 我已经有了PhpStorm 10.0.3,并尝试调试在远程服务器上运行的CLI脚本。

I've got reverse SSH tunnel set up from my local machine to the remote server. 我已经从本地计算机到远程服务器建立了反向SSH隧道。

Remote server xDebug is configured with the following: 远程服务器xDebug使用以下配置:

# /etc/php5/apache2/conf.d/20-xdebug.ini
# /etc/php5/cli/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=true
xdebug.idekey=PHPSTORM
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

I try to start a script like this: 我尝试启动这样的脚本:

 php -dxdebug.remote_autostart=On /var/www/index.php

The PhpStorm debug tabs get's opened (sometimes it's gray), but it does not prompt me to fix file mappings, it does not open the debugged file and does not point to the breakpoint line. PhpStorm调试选项卡被打开(有时为灰色),但是它不会提示我修复文件映射,它不会打开调试的文件,也不会指向断点行。 The remote server script execution gets blocked until I manually kill the debugging session. 在我手动终止调试会话之前,远程服务器脚本的执行将被阻止。 在此处输入图片说明

When I debug over Apache2 using GET parameter: 当我使用GET参数在Apache2上调试时:

 ?XDEBUG_SESSION_START=1 

The debugging works fine and I get prompted to fix the file mappings. 调试工作正常,系统提示我修复文件映射。

Any idea why is that? 知道为什么吗?

I was studying below, but it does not solve my problem: https://confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+CLI+scripts+with+PhpStorm (Question: How my script should now that debugging should start without remote_autostart setting set? In green hint they say it is optional.) 我在下面学习,但不能解决我的问题: https : //confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+CLI+scripts+with+PhpStorm (问题:现在我的脚本应该如何开始调试没有设置remote_autostart设置吗?在绿色提示中,他们说这是可选的。)

and XDebug: how to debug remote console application? XDebug:如何调试远程控制台应用程序? (Re: Setting the remote_host in the XDEBUG_CONFIG variable to my local computer external IP [check the copied bash snippet] does not seem to be working. My local computer is not accessible via external IP, it's only accessible via reverse SSH tunnel) (回复:将XDEBUG_CONFIG变量中的remote_host设置为我的本地计算机外部IP [检查复制的bash代码段]似乎不起作用。我的本地计算机无法通过外部IP访问,只能通过反向SSH隧道访问)

 export XDEBUG_CONFIG="remote_host=$(echo $SSH_CLIENT | awk '{print $1}') idekey=PHPSTORM"

There were actually 2 problems here. 实际上这里有两个问题。 As in the @LazyOne comment, there was a port collision with the PHP5-FPM service. 就像@LazyOne注释一样,PHP5-FPM服务存在端口冲突。 In my case I've turned it off, as the client's server configuration does not use FPM anyway. 就我而言,我已将其关闭,因为客户端的服务器配置始终不使用FPM。

I also had to export PHP_IDE_CONFIG variable on the remote host: 我还必须在远程主机上导出PHP_IDE_CONFIG变量:

 export PHP_IDE_CONFIG="serverName=serverNameInPHPStorm"

That host is a configured on the PHPStorm side (Settings / Preferences | Languages & Frameworks | PHP | Servers). 该主机是在PHPStorm端配置的(设置/首选项|语言和框架| PHP |服务器)。 I've also had to map the root project folder on the remote server path location, as they are different between my local/dev machine and the remote. 我还必须将根项目文件夹映射到远程服务器路径位置,因为它们在我的本地/ dev计算机和远程计算机之间是不同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM