【问题标题】:How to make php-debug extension with Valet on Ubuntu - 502 Bad Gateway如何在 Ubuntu 上使用 Valet 进行 php-debug 扩展 - 502 Bad Gateway
【发布时间】:2019-01-27 05:08:46
【问题描述】:

我正在调试一个带有解析错误的简单 index.php:

<?php

echo '<h1> Hello </h1>';

$value = 0;

if($value == 0){
    echo "true";
}else{
    echo "false"
}

我已经在我的 Ubuntu 上配置了 php-debug/Xdebug,设置是从不同的论坛读取的,但它并没有像我希望的那样工作。

它不加载本地变量,而是打开一个 server.php。

Chrome 显示:502 Bad Gateway。

有人遇到过这个错误吗?

安装详情

操作系统 说明:Ubuntu 16.04.4 LTS 发布时间:16.04 代号:xenial

Xdebug解析的phpinfo()

    Xdebug installed: 2.6.1
Server API: Command Line Interface
Windows: no
Zend Server: no
PHP Version: 7.2.9-1
Zend API nr: 320170718
PHP API nr: 20170718
Debug Build: no
Thread Safe Build: no
Configuration File Path: /etc/php/7.2/cli
Configuration File: /etc/php/7.2/cli/php.ini
Extensions directory: /usr/lib/php/20170718

代客2.0.24版 当前 Nginx 端口(HTTP):80 当前 Nginx 端口(HTTPS):443## Heading ##

Xdebug.ini

zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change

Launch.JSON

{ "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9000 }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port":
9000 } ] }

【问题讨论】:

  • 你的 xdebug.ini 中有什么?你可以通过php --ini找到这个文件的位置。
  • 感谢您对艾玛德的回复。通过编辑问题添加了 Xdebug.ini
  • 嗯,我记得设置起来很棘手,但不记得“catch”。我的 xdebug.ini(有效)只有 remote_enableremote_autostartremote_port 与您的值相同,以及 zend_extension=xdebug.so。您可以尝试注释掉/删除其他行并运行valet restart 吗?我也在使用 valet-linux 的 Ubuntu 16.04。
  • 还有一件事:你不是在 php 的内置服务器中运行它,对吧?
  • @amade 感谢您的意见。尝试了这些步骤。我收到 http 错误代码 500。我在名为 debug 的目录中有这个 index.php。目录是代客泊车的。我在地址栏中输入 debug.test。在 chrome 中打开之前,我将在 VScode 中进入调试模式,并监听 xdebug。我也试过输入 debug.test:9000 也没有成功

标签: php ubuntu nginx visual-studio-code valet


【解决方案1】:

我用 Xdebug 和 VScode 为 Valet 发布的这个设置是正确的。它将为您的配置。我对 Xdebug 调试解析错误的期望是不正确的。解析错误应该在调试之前被删除。下面是来自 stackoverflow 用户 Amade 的富有洞察力的评论:

好的,在这种情况下,你一开始就做对了,只是我 认为对代客的 xdebug 有某种错误的期望。它会 从代客打开 server.php,因为这是带有语法的文件 错误是必需的。我不认为有什么真的你可以 去做吧。但是当你使用 VSCode 时,你不明白吗? 面板中的语法错误通知?你可以打开它 ctrl+j

【讨论】:

    猜你喜欢
    • 2022-01-24
    • 2022-08-16
    • 1970-01-01
    • 2019-12-17
    • 2017-05-31
    • 2017-08-20
    • 2017-06-29
    • 2021-12-19
    • 2016-09-14
    相关资源
    最近更新 更多