php - 在 Ubuntu LAMP 堆栈上安装 xdebug

标签 php ubuntu-14.04 xdebug

我一直抛出此错误,但我安装了版本 7.1.2。为什么我不能 ./configure

这是我的错误消息:

checking whether to enable Xdebug support... yes, shared
checking Check for supported PHP versions... configure: error: not supported. 
Need a PHP version >= 7.0.0 and < 7.3.0 (found 5.3.10-1ubuntu3.26)
    root@precise32:/var/www/xdebug# php -v
    PHP 7.1.2-3+deb.sury.org~precise+1 (cli) (built: Feb 22 2017 10:29:40) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
        with Zend OPcache v7.1.2-3+deb.sury.org~precise+1, Copyright (c) 1999-2017, by Zend Technologies
    root@precise32:/var/www/xdebug# 

还有其他人遇到过这个问题吗?我尝试过重新安装 php 7.0 和其他几种策略。阅读一堆类似的不同堆栈问题,但我无法弄清楚。

这意味着我无法继续:make

make install

cp modules/xdebug.so /etc/php.d/xdebug.so

最佳答案

您正在使用 Ondřej Surý 的 PPA。因此,您可以使用apt-get install php7.1-xdebug轻松安装xdebug。

编辑:如何配置 Xdebug(在基于 Ubuntu 的 Linux 系统上):

创建一个ini文件/etc/php/7.1/mods-available/custom.ini并将以下配置放入其中:

; priority=90
[xdebug]
xdebug.remote_enable=1
; replace <Host-IP-Address> with the IP of your host system!
xdebug.remote_host=<Host-IP-Address>
; You'll need this later.
xdebug.idekey=PHPSTORM
xdebug.profiler_enable_trigger=1

现在使用命令sudo phpenmod -v 7.1 -s ALL custom激活配置。不要忘记重新启动您的网络服务器。

其次,您需要一个支持 dbgp 协议(protocol)的 IDE。我使用 PhpStorm,它速度很快(即使运行几个小时),而且它有原生的 Xdebug 支持。

设置 IDE 并在代码中设置至少一个断点后,您可以非常简单地触发调试器:

第一个选项:添加查询参数 XDEBUG_SESSION_START=PHPSTORM (其中 PHPSTORM 是配置文件中 xdebug.idekey 设置的值)。

第二个选项:根据您的请求发送包含 XDEBUG_SESSION=PHPSTORM 内容的 cookie。 cURL 示例:curl -H 'Cookie: XDEBUBG_SESSION=PHPSTORM' http://my-awesome.domain/awesome-script.php

如果您已正确设置任何内容,现在就可以使用 Xdebug 了。

Xdebug - Documentation
PhpStorm - Configuring Xdebug
PhpStorm - Zero-configuration Web Application Debugging with Xdebug and PhpStorm

最后但并非最不重要的一点是,一些不错的 Xdebug 设置:

; enable colors for the command-line interface
xdebug.cli_color=1

; show more data when using var_dump
xdebug.max_nesting_level=500
xdebug.var_display_max_children=512
xdebug.var_display_max_data=2560
xdebug.var_display_max_depth=200

; enable trigger for easy profiling
xdebug.profiler_enable_trigger=1

祝调试 session 愉快:)

关于php - 在 Ubuntu LAMP 堆栈上安装 xdebug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42542013/

相关文章:

javascript - 如何对两个数组进行json编码并在ajax中使用它们

phpstorm - 无法解析外部 Xdebug 连接的服务器名称

php - 调试IDE的端口连接到XDebug : "Waiting to Connect"

php - 无法加载动态库 'newrelic.so'

php - 将字符串从 html 文件中的表单传递到符合 utf-8 编码的 python 脚本

php - MySQL 和 PHP - 从数据库获取最后的评论

linux - 将文本从 Windows 复制并粘贴到远程 Linux 文件

linux - 使用 sudo chmod 命令将/usr 文件权限更改为 0744

android - ubuntu14.04构建android4.4调制解调器报错

php - Eclipse Indigo 无法在外部 Web 浏览器上运行 PHP 页面