docker - 带有 docker 容器、反向代理中的 nginx 和 https 的 PhpStorm 调试器
问题描述
我需要一些帮助才能使用特定的开发配置来配置 PhpStorm 调试器。在我的电脑(192.168.1.23)上,我有一个 PHP 项目的源代码、一个 dbms 和一个 nginx 实例作为反向代理。配置 Nginx 是为了将所有流量发送到 docker 容器:
server {
listen 80;
listen [::]:80;
server_name www.mysite.local;
root /usr/share/nginx/html/;
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location / {
index index.html index.php;
}
}
upstream backend {
# configuration in order to use apache inside docker container
server 172.17.0.2:80;
}
docker 容器 (172.17.0.2) 已创建:
docker run -dP --add-host=db.local:172.17.0.1 \
-e remote_connect_back_xdbg=1 \
-e remote_host_xdbg='192.168.1.23' \
-v /opt/live:/opt/live \
--name local_php_apache_container local_php_apache_image
所以 Docker 将我的项目(位于 /opt/live)安装在容器的 /opt/live 内。该容器是带有 PHP 5.3 + Apache2 的 Debian 9。它会在电脑启动时使用以下命令自动启动:
docker exec -it local_php_apache_container /bin/bash
在 docker 容器内部,php.ini 中的 xdebug 配置为:
[xdebug]
xdebug.remote_connect_back=${remote_connect_back_xdbg}
xdebug.remote_enable=1
xdebug.remote_port=10123
xdebug.remote_handler=dbgp
xdebug.remote_log=/stackdriver/log/xdebug.log
xdebug.remote_mode=req
xdebug.remote_autostart=1
xdebug.remote_host=${remote_host_xdbg}
xdebug.idekey="netbeans-xdebug"
idkey 是 netbeans-xdebug,因为使用 netbeans,调试器可以正常工作(https://www.mysite.local/index.php?XDEBUG_SESSION_START=netbeans-xdebug,带有本地不受信任证书的 https)
但是我对 PHPStorm 和 PHP 解释器的位置有很多问题,包括 PHP 内置 Web 服务器和 PHP 远程调试配置......有什么建议吗?
解决方案
推荐阅读
- total.js - 一次性使用 Total js 中的数据绑定和 SET 方法为所有表单元素设置值
- javascript - 在 TypeScript 中未找到存储库错误,当我通过 typeorm 连接到 MySQL 时遇到错误
- c - 关于 RISC-V 编译器?
- android - Android:导航组件不能同时使用:
和 NavigationItemSelectedListener - time - 计算从上午 12 点开始的工作时间
- c# - 优化 INSERT、DELETE、UPDATE SQL Server 表的简单方法包括具有图像数据类型的列,无需实体框架,分 3 个步骤(C#)
- java - 我们如何在 Spring Rest 控制器中解析 rpc 格式的 xml 请求?
- vb.net - 计时器案例在 y 中包含 x
- git - 如何从 Gitlab 提交历史中删除我的电子邮件?
- distributed-system - 两阶段提交是否安全