php - 在 Ubuntu 上使用 PhpStorm 进行 Xdebug
问题描述
我想知道是否有人可以阐明要采取的适当措施,以确保以下设置将允许 Xdebug 和 PhpStorm 工作。
我们的 LAMP 堆栈运行良好,PHP 和 Xdebug 3 在 Azure VM 上运行。
我们在一个共享的办公网络上,有一个公共 IP 地址,但没有访问防火墙的传入线路,尽管它非常轻松。
我们的目标是连接我们的机器 (x3) 以调试我们的远程 Web 服务器(Azure VM 上的 LAMP 堆栈)。
我们可以毫无问题地创建到 Web 服务器的 SSH 隧道。但是调试是行不通的。即当我们启动一个页面时,调试器什么都不做。
是否有其他人在运行这种设置并确认我们是否缺少确保连接成功的步骤。
[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.default_enable = 1
xdebug.force_display_errors = 1
xdebug.scream = 1
xdebug.force_error_reporting = NONE
xdebug.idekey = diss
xdebug.remote_enable = 1
xdebug.remote_log=/tmp/xdebug.log
xdebug.log=/var/log/xdebug.log
xdebug.remote_connect_back=0
xdebug.discover_client_host=false
解决方案
在我的情况下,通过确保设置如下解决了这个问题
[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.remote_log=/tmp/xdebug.log
xdebug.log=/var/log/xdebug.log
我使用 pydbgpproxy
cd /opt
sudo mkdir pydbgpproxy
cd pydbgpproxy
sudo wget https://github.com/Mirocow/pydbgpproxy/archive/master.zip ./
sudo unzip master.zip ./
sudo ln -s $(pwd)/pydbgpproxy /usr/local/bin/pydbgpproxy
编辑 pydbgpproxy
cd /opt/pydbgpproxy/pydbgpproxy-master/
sudo nano pydbgpproxy
在第 333 行将 add=xxx 行替换为
addr = ['127.0.0.1',long(idekey)]
在服务器上启动 pydbgproxy
nohup sudo /opt/pydbgpproxy/pydbgpproxy-master/pydbgpproxy -i 127.0.0.1:1001-d 127.0.0.1:1003 &
使用 SSH 隧道创建与开发服务器的 SSH 连接:
Source Port: 1234 **This must match your unique IDE key set below.**
Destination: 127.0.0.1:1003
在 PhpStorm 中将调试器端口更改为 9003
File > Settings > Languages & Frameworks > PHP > Debug
Debug Port: 1003
将您的代理设置更改为:
File > Settings > Languages & Frameworks > PHP > Debug > DBGp Proxy
IDE Key: 1234 **Unique IDE Key - This must be unique to you and must be numerical**
Host: 0.0.0.0 **External IP Address of the Dev Server**
Port: 1001
确保您的 xdebug 帮助程序扩展设置为使用密钥 1234
您在上面设置为 IDE 密钥的内容必须是唯一的
推荐阅读
- javascript - 在 JS/ES6 中获取枚举键的文字字符串
- amazon-web-services - 如何创建一个蟒蛇蛋?并火花提交
- javascript - Javascript 对象变量常量
- mongodb - 如何优化聚合查询以根据不同的键进行分组?
- java - GCP App Engine 上的 Spring Security 为每个请求挂起 30 多秒,然后出错
- sql - 雪花环境下sql查询数据校验
- c# - 有没有办法从 aspx.cs 更新引导进度条宽度?
- c - 使用 ffi 在 dart 中绑定 c 库的过程是什么?
- php - 如何在会话中存储多个表单 $_POST
- php - 如何在php中使用curl发送文件