在 Ubuntu LAMP 堆栈上安装 xdebug [英] Installing xdebug on Ubuntu LAMP stack

查看:30
本文介绍了在 Ubuntu LAMP 堆栈上安装 xdebug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在抛出这个错误,但我安装了 7.1.2 版.为什么我不能./configure

I keep throwing this error but I have version 7.1.2 installed. Why can't I ./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 和其他几种策略.通读一堆类似的不同堆栈问题,但我无法弄清楚.

Has anyone else encountered this problem. I've tried reinstalling php 7.0 and several other tactics. Read through a bunch of different stack questions similar but I can't figure it out.

这意味着我不能继续:make

make install

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

推荐答案

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

You're using the PPA from Ondřej Surý. So you can easily install xdebug by using apt-get install php7.1-xdebug.

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

How-To configure Xdebug (on Ubuntu based Linux systems):

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

Create an ini file /etc/php/7.1/mods-available/custom.ini and put the following configuration into it:

; 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 激活配置.不要忘记重新启动您的网络服务器.

Now activate the configuration with the command sudo phpenmod -v 7.1 -s ALL custom. Don't forget to restart your web server.

其次,您需要一个支持 dbgp 协议的 IDE.我使用 PhpStorm,它速度很快(甚至可以运行几个小时),当然,它具有原生 Xdebug 支持.

Second you need an IDE which supports the dbgp protocol. I use PhpStorm, it's fast (even it runs for hours) and of cause, it has a native Xdebug support.

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

After you've set up your IDE and set at least one breakpoint in your code, you can trigger the debugger very simple:

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

1st option: Add the query parameter XDEBUG_SESSION_START=PHPSTORM (where PHPSTORM is the value of the xdebug.idekey setting in your configuration file).

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

2nd option: Send a cookie with the content XDEBUG_SESSION=PHPSTORM with your request. cURL example: curl -H 'Cookie: XDEBUBG_SESSION=PHPSTORM' http://my-awesome.domain/awesome-script.php.

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

If you've set up anything correctly, you can now play with Xdebug.

Xdebug - 文档
PhpStorm - 配置 Xdebug
PhpStorm - 零配置Web使用 Xdebug 和 PhpStorm 调试应用程序

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

And last but not least, some nice-to-have Xdebug settings:

; 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

祝您调试愉快 :)

这篇关于在 Ubuntu LAMP 堆栈上安装 xdebug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆