【发布时间】: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_enable、remote_autostart、remote_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