【问题标题】:502 Bad Gateway when debugging php 7 Xdebug 2.4.0RC3 mac os调试 php 7 Xdebug 2.4.0RC3 mac os 时出现 502 Bad Gateway
【发布时间】:2016-04-15 18:14:54
【问题描述】:

我正在使用最新版本的PHP (7.0.2)xdebug (2.4.0RC3)phpstorm 9.0.2,当我开始调试时,我立即得到了

error "502 Bad Gateway"

有时我设法通过几行代码,但我还是得到了错误。

当我拥有以前版本的 PHP (5.6)xdebug 时,一切都很棒。

附: php、nginx 和 xdebug 是用 homebrew 安装的。

【问题讨论】:

标签: php nginx homebrew xdebug


【解决方案1】:

你可以试试这个: 打开你的 php.ini,对不起,我不知道它在 MacOS 中的位置,在 Ubuntu 中它在

/etc/php/7.0/fpm/php.ini

使用您喜欢的文本编辑器打开它,并具有保存配置文件所需的权限。 转到 xdebug 部分并检查您是否已正确设置它。就我而言,它看起来像下面。请注意,在您的情况下,xdebug.so 的路径可能不同。

[Xdebug]
zend_extension="/usr/lib/php/20151012/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="\tmp"
xdebug.idekey="PHPSTORM"
xdebug.remote_autostart=1
xdebug.remote_host=192.168.10.10
xdebug.remote_mode=req
xdebug.remote_connect_back=1
xdebug.max_nesting_level=200
xdebug.var_display_max_depth=1000
xdebug.var_display_max_children=256
xdebug.var_display_max_data=4096

;this line below to prevent debug stop timeout
request_terminate_timeout=600s

在 php.ini 中检查的另一件事是

max_execution_time = 600

我已将其设置为如上所述以防止停止调试会话,默认设置为 30 秒

接下来需要检查的是 nginx 配置,我已将这些行添加到主 nginx.conf http 部分

http {

    proxy_connect_timeout 600s;
    proxy_send_timeout 600s;
    fastcgi_read_timeout 600s;
    proxy_read_timeout 600s;
    fastcgi_buffers 8 16k;
    fastcgi_send_timeout 600s;
    fastcgi_buffer_size 32k;

   #other standard settings below...

我添加它们是为了给我更多的时间来调试会话,这样它就不会在 600 秒内停止。

在所有编辑之后。 重启php7.0-fpm和nginx。 我不确定它是如何在 Ubuntu 的 MacOS 中完成的:

 sudo service php7.0-fpm reload
 sudo service php7.0-fpm restart
 sudo service nginx reload
 sudo service nginx restart

也许重新加载然后重新启动但要保险:)

还请查看您的 nginx 的 error.log 文件 在 Ubuntu 中,它们位于 /var/logs/nginx/ 有error.yourdomain.log 转到最后几行,看看发生了什么。 希望它会有所帮助。

UPD:对于任何将 Homestead 与 ngrok 隧道一起使用的人(或者例如 ssh -R 3000:localhost:8000 user@yourserver.domain,然后在公共站点上,您将设置 nginx 作为端口 80 上某个域的反向代理,以通过 SSH 从 3000 隧道读取)将本地开发暴露给互联网。

要启用调试,您需要注释掉行 xdebug.remote_connect_back=1 或将其值设置为 0。否则 xdebug 会得到 X-Forwarded-For 和其他头文件,并会尝试连接回 nginx,但不会连接到您的本地 dev,并且无法开始调试。

【讨论】:

    【解决方案2】:

    由于某种原因,当我从模式中删除 profile 时,它会为我修复它。

    即改变

    xdebug.mode=debug,develop,profile
    

    xdebug.mode=debug,develop
    

    【讨论】:

      猜你喜欢
      • 2015-05-17
      • 1970-01-01
      • 2021-08-03
      • 2015-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-29
      • 2015-11-02
      相关资源
      最近更新 更多