Xdebug的在泊坞窗不工作的Mac
问题描述:
后,我从泊坞窗机切换到多克的Mac XDebug的已停止工作。主机上的端口9000无法从具有xdebug的容器中访问。
的php.ini:
Xdebug的在泊坞窗不工作的Mac
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=172.18.0.1
xdebug.idekey=PHPSTORM
搬运工-compose.yml:
version: '2'
services:
php:
image: <image name>
ports:
- 80:80
# - 9000:9000
volumes:
- .:/var/www/html
- ./php.ini:/usr/local/etc/php/conf.d/php.ini
xdebug.log:
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
I: Remote address found, connecting to 172.18.0.1:9000.
E: Could not connect to client. :-(
是否解决我的问题?
答
我有同样的问题。这可能与OSX中docker的局限性有关。看到这些链接。
https://docs.docker.com/docker-for-mac/networking/ https://forums.docker.com/t/explain-networking-known-limitations-explain-host/15205
可能的解决方法也被建议。其中之一就是创建一个带有新的IP的设备(例如10.254.254.254),该设备将循环回到本地主机。当你使用这个ip作为远程主机地址而不是由docker(127.0.0.1或172.17.0.2)分配的地址时,它应该做到这一点。按照this link的编码解决方案
答
您的码头工人,compose.yml更改为以下。
您将要暴露的端口9000,不绑定。同时更新你的xdebug ini到你的主机(mac)的ip而不是docker的ip。
我还添加了如何从你的Mac直接安装Xdebug的文件到您的码头工人,这样你就可以在飞行中进行更新。这允许你更多的控制,因为你可能需要更新你的IP从移动到WiFi的基础。 xdebug.remote_host = ip应该是你的mac本地网络ip。只要记住,如果你在apache上执行service apache2 restart
或者任何时候更改IP地址的适当命令来重新启动服务器。
version: '2'
services:
php:
image: <image name>
ports:
- 80:80
expose:
- "9000"
volumes:
- .:/var/www/html
- ./php.ini:/usr/local/etc/php/conf.d/php.inivolumes:
- ./20-xdebug.ini:/etc/php/7.1/cli/conf.d/20-xdebug.ini //obviously you would change this to your correct paths
- ./20-xdebug.ini:/etc/php/7.1/apache2/conf.d/20-xdebug.ini //obviously you would change this to your correct paths
# 20-xdebug.ini, this is how mine is setup.
zend_extension = /usr/lib/php/20160303/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=192.168.0.4 // Make sure you use your host (mac) local ip, not the ip of docker.
xdebug.remote_port=9000
xdebug.idekey = PHPSTORM
xdebug.remote_handler = dbgp
xdebug.remote_autostart = 1
xdebug.remote_log = /var/log/xdebug.log
Tnaks!它帮助了我! –
谢谢。你发布的要点(https://gist.github.com/ralphschindler/535dc5916ccbd06f53c1b0ee5a868c93)是完美的。 –