简体   繁体   English

PhpStorm远程Xdebug

[英]PhpStorm remote Xdebug

I've got problems with setting up Remote Web Server Debugging with Xdebug. 使用Xdebug设置远程Web服务器调试时遇到问题。 I keep getting 404 error: 我不断收到404错误:

在此处输入图片说明

but actually Xdebug is being detected correctly: 但实际上Xdebug被正确检测到:

在此处输入图片说明

How are machines setup 机器如何设置

  • Laptop and Desktop PC are connected in the same network 笔记本电脑和台式电脑连接在同一网络中
  • Laptop has Ubuntu 18 installed and I'm using it as server 笔记本电脑已安装Ubuntu 18,并且正在将其用作服务器
  • There is a Docker on laptop with file sync but this doesn't matter at this point 笔记本电脑上有一个具有文件同步功能的Docker,但现在这并不重要
  • PhpStorm is on my Desktop PC, PhpStorm在我的台式机上,
  • Vsftpd is configured correctly, files edited on Desktop are being sent on laptop and page data is being update in container, Vsftpd配置正确,正在笔记本电脑上发送在桌面上编辑的文件,并且正在容器中更新页面数据,
  • my website works locally at 192.168.1.103 我的网站在192.168.1.103本地工作

What works fine at this point 这时什么工作正常

  • FTP connection with laptop, 与笔记本电脑的FTP连接,
  • SFTP connection with laptop, 与笔记本电脑的SFTP连接,
  • SSL, SSL,
  • SSH connection from desktop via for example Git Bash, 通过Git Bash从桌面进行SSH连接,
  • Xdebug itself works fine on laptop. Xdebug本身可以在笔记本电脑上正常工作。

What I already tried 我已经尝试过的

zend_extension=/usr/lib/php/20170718/xdebug.so
    xdebug.remote_autostart = 1
    xdebug.remote_enable = 1
    xdebug.remote_handler = dbgp
    xdebug.remote_host = 127.0.0.1
    xdebug.remote_log = /tmp/xdebug_remote.log
    xdebug.remote_mode = req
    xdebug.remote_port = 9005
  • I've tried with changed remote host to the IP on which website works, didn't helped. 我尝试将远程主机更改为网站可以使用的IP,但没有帮助。
  • Also Apache DocumentRoot was setup on /var/www while my project was somewhere else so I move project to /var/www and still nothing - but works OK on given IP above. 另外,当我的项目位于其他地方时,Apache DocumentRoot也已在/var/www上安装,因此我将项目移至/var/www ,但仍然没有任何内容-但可以在上述给定IP上正常运行。

I'm out of ideas at this point. 我现在还没主意。

PS I'm newbie to Linux. PS我是Linux的新手。

First of all I'm unable to pinpoint what was exactly the problem, however I've got few ideas looking on what I've changed and it suddenly started to work. 首先,我无法确定到底是什么问题,但是我对更改的内容知之甚少,并且突然开始起作用。

Step by step what I've made in order to make connection work this time. 为了使这次连接正常,请逐步进行操作。

  1. Creating new remote project 创建新的远程项目
  2. Defining connection with FTP (in my case I'm connecting to my laptop with Ubuntu) 定义与FTP的连接(在我的情况下,我要使用Ubuntu连接到笔记本电脑)

在此处输入图片说明

At this point the difference is that: 在这一点上,不同之处在于:

  • I've pointed the location manually 我已手动指出位置
  • I've changed the Web server root URL, previously it was just IP without port etc 我已经更改了Web服务器的根URL,以前它只是IP,没有端口等

Next thing is Mapping. 接下来是映射。 Once I've setup correct path in Connection tab all I had to do is: 在“连接”选项卡中设置正确的路径后,我要做的就是:

在此处输入图片说明

  1. Selecting CLI and Path mapping 选择CLI和路径映射

Once the connection is established, There will be list of detected remote CLI Interpreters. 建立连接后,将显示检测到的远程CLI解释器的列表。 I've picked up my Laptop's Ubuntu. 我已经拿起笔记本电脑的Ubuntu。 Again keep an eye on Path mappings, it should be the same Root Path above. 再次注意路径映射,它应该与上面的根路径相同。

在此处输入图片说明

Now once You press the marked button in CLI line, You will see new windows. 现在,一旦您在CLI行中按下标记的按钮,您将看到新窗口。 In my case xdebug was detected. 在我的情况下,检测到xdebug。

在此处输入图片说明

Press „Open in Editor” 按“在编辑器中打开”

  1. Xdebug settings Xdebug设置

Below are the settings I've got in php.ini: 以下是我在php.ini中获得的设置:

zend_extension = /usr/lib/php/20170718/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_connect_back = 1
xdebug.remote_host = "192.168.1.100" //This is my Desktop PC IP
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9101 //This is the port under which I want xdebug to work remotely
xdebug.idekey = "PHPSTORM"

Below are settings for my Xdebug.ini file on Ubuntu (the same as above): 以下是我在Ubuntu上的Xdebug.ini文件的设置(与上面相同):

在此处输入图片说明

It's worth mentioning that I had 127.0.0.1 as remote_host and Validation tool actually detected my Desktop IP this time. 值得一提的是,我有127.0.0.1作为remote_host,而Validation工具这次实际上检测到了我的桌面IP。

  1. Validating Xdebug connection 验证Xdebug连接 在此处输入图片说明

Keep an eye on underlined sections – this are my settings. 请注意带下划线的部分-这是我的设置。 Now go to Validate. 现在转到验证。

Upon pressing Validate, You should see settings like these below. 按下验证后,您应该在下面看到类似的设置。 Again be sure to pick up proper Remote connection. 再次确保获得正确的远程连接。

在此处输入图片说明

The rest goes just with the official guide – setup Xdebug extension in browser and start listening for incoming connections. 剩下的只是官方指南-在浏览器中设置Xdebug扩展并开始监听传入的连接。

Below are some useful links that might be helpful in case You will have some other kind of problems. 以下是一些有用的链接,这些链接在您遇到其他问题时可能会有所帮助。

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

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