我已經閱讀了一些關於此的帖子,但沒有人幫助過我的情況,或者只是忽略了缺少的部分。在PhpStorm中通過Docker容器使用xdebug
我無法讓xdebug在使用Docker容器的PhpStorm上工作。
多克爾-compose.yml
version: '2'
services:
web:
image: nginx:latest
volumes:
- .:/usr/share/nginx/html
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/logs:/var/logs/nginx
- ./nginx/site-enabled/default.conf:/etc/nginx/sites-enabled/default.conf
ports:
- "80:80"
depends_on:
- php
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: 1234
MYSQL_DATABASE: local_db
MYSQL_USER: root
MYSQL_PASSWORD: 1234
ports:
- "3306:3306"
php:
build: images/php
volumes:
- .:/usr/share/nginx/html
- ./config/docker/php/php.ini:/usr/local/etc/php/php.ini
- ./config/docker/php/ext-xdebug.ini:/usr/local/etc/php/conf.d/ext-xdebug.ini
- ./config/docker/php/php-fpm.conf:/usr/local/etc/php-fpm.conf
user: www-data
depends_on:
- db
配置/搬運工/從xdebug.log
Log opened at 2017-05-31 11:01:14
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.20.0.1:9000.
W: Creating socket for '172.20.0.1:9000', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2017-05-31 11:01:14
PHP/EXT-xdebug.ini
zend_extension="/usr/lib/php7/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.overload_var_dump=1
xdebug.default_enable=1
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_connect_back=1
xdebug.remote_host=172.20.0.1 # ip of host inside docker container
xdebug.remote_log=/usr/share/nginx/html/xdebug.log
錯誤
在PhpStorm我使用遠程調試器,設置如下:
服務器
Host - 127.0.0.1
Port - 80
在服務器上的絕對路徑
/usr/share/nginx/html
IDE會話密鑰
PHPSTORM
kill phpstorm,並檢查您的主機,如果端口9000被其他進程使用。如果是這樣,您可能需要在php設置和phpstorm中更改xdebug端口。 – YvesLeBorg
沒有使用這個端口的進程,除了phpstorm啓動時 – xhallix