-
Notifications
You must be signed in to change notification settings - Fork 52
使用疑问
何凌枫 edited this page Aug 14, 2018
·
1 revision
volumes:
- ./www/:/var/www/html/:rw
将 ./www/
修改为你的 workspace
工作目录,可以修改.env
文件
php-fpm
应用添加 extra_hosts
指向 nginx
应用
extra_hosts:
- www.demo1.com:172.100.0.2
这里的 172.100.0.2
表示 nginx
应用ip
nginx
配置文件 .conf
选项 fastcgi_pass
参数定义
fastcgi_pass fpm56:9000;
或者
fastcgi_pass fpm72:9000;
以 php72
应用为例,首先需要修改 Dockerfile
文件,安装 xdebug
扩展;
PECL extensions
安装说明可以在官网找到:
https://hub.docker.com/_/php/
RUN pecl install xdebug-2.6.0 \
&& docker-php-ext-enable xdebug
重新构建 php72
镜像(删除镜像,启动docker-compose
)
修改 php72.ini
文件追加
xdebug.auto_trace = on
xdebug.default_enable = on
xdebug.auto_profile = on
xdebug.collect_params = on
xdebug.collect_return = on
xdebug.profiler_enable = on
xdebug.remote_enable = on
xdebug.remote_port = 9005
xdebug.remote_handler = dbgp
xdebug.remote_autostart = on
xdebug.remote_connect_back = on
; 配置这个可以查看调试日志
xdebug.remote_log = /var/log/php-fpm/xdebug_remote.log
;xdebug.trace_output_dir = "/var/log/php-fpm/xdebug/"
;xdebug.profiler_output_dir = "/var/log/php-fpm/xdebug/"
xdebug.idekey = PHPSTORM
端口一致即可,上述我配置的是9005
端口
参看一下这个文档:https://www.jianshu.com/p/e9ad4c99d118
设置断点,点击开始调试时,并没有成功进入调试模式。
查看 xdebug_remote.log
日志,报错如下
Log opened at 2018-06-01 13:51:09
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.100.0.1:9005.
W: Creating socket for '172.100.0.1:9005', poll success, but error: Operation now in progress (29).
E: Could not connect to client. :-(
Log closed at 2018-06-01 13:51:09
根据下面资料:
- https://forums.docker.com/t/solved-how-to-setup-xdebug-and-phpstorm/13641/2
- https://stackoverflow.com/questions/44283171/using-xdebug-through-docker-container-in-phpstorm?rq=1
; 这个地址为主机ip,通过`ifconfig`查看
xdebug.remote_host = 192.168.1.123
xdebug.remote_connect_back = 0
注意:配置远程目录映射