我正在尝试对在过去几个月中运行良好的Ubuntu上的Docker / PHP-Xdebug / VSCode环境进行故障排除。现在xdebug可以连接到客户端了。
使用docker exec --tty --interactive bw bash
进入Docker
php -v
返回
PHP 7.2.14 (cli) (built: Feb 6 2019 05:10:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
而php -m -c
在[Zend模块]部分列出了Xdebug。
这是.ini部分
[xdebug]
xdebug.default_enable = 1
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.idekey = VSCODE
xdebug.remote_handler = "dbgp"
xdebug.remote_port = 9000
xdebug.remote_log=/var/log/apache2/xdebug.log
xdebug.remote_timeout = 500
其中的一切反映在phpinfo()
输出中。
docker-compose.yml
version: "3.1"
services:
webserver:
build: docker/apache
container_name: bw
volumes:
- .:/var/www/html
ports:
- "8000:80"
expose:
- "9000"
restart: always
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log":true,
"pathMappings": {
"/var/www/html": "${workspaceRoot}/",
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
} ]
}
这是xdebug.log的尾巴
[156] Log opened at 2019-08-05 19:39:58
[156] I: Checking remote connect back address.
[156] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[156] I: Checking header 'REMOTE_ADDR'.
[156] I: Remote address found, connecting to 172.18.0.1:9000.
[156] E: Time-out connecting to client (Waited: 500 ms). :-(
[156] Log closed at 2019-08-05 19:39:59
我强烈怀疑我缺乏Docker知识是重新进行这项工作的问题。
任何帮助将不胜感激。
答案 0 :(得分:0)
问题出在主机的防火墙上。无法真正说出规则消失的原因/原因。
我在用telnet探测端口时使用了错误的方式,这使我想到防火墙正在允许流量通过。
实际上,主机上的with open('data.txt', 'r') as f_in:
next(f_in) # skip headers
data = []
for line in f_in:
data.append(line.split())
items = {}
for name, value in data:
items[name] = items.get(name, 0) + int(value)
print('{: <10}{}'.format('NAME', 'VALUE'))
for name, value in items.items():
print('{: <10}{}'.format(name, value))
确实重建了所有内容。