php 是否可以在 Ubuntu 上使用 xdebug?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5504152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:38:55  来源:igfitidea点击:

Is it possible to use xdebug on Ubuntu?

phpubuntuxdebug

提问by Genadinik

I am trying to debug some PHP code and wanted to download the XDebug debugger for PHP. All I see there is Windows binaries for downloading. Is it at all possible to use it on Ubuntu?

我正在尝试调试一些 PHP 代码并想下载用于 PHP 的 XDebug 调试器。我所看到的只有 Windows 二进制文件可供下载。是否可以在 Ubuntu 上使用它?

回答by Jarrod Nettles

Execute the following commands in your terminal.

在终端中执行以下命令。

Download Xdebug - you will need to follow alternate instructions if you don't have PHP5 working on your machine already.

下载 Xdebug - 如果您的机器上还没有 PHP5,则需要按照替代说明进行操作。

sudo apt-get install php5-xdebug

The package should modify your INI file for you, but just in case you need to edit it yourself open it up and make the following modification - on Ubuntu its typically at /etc/php5/apache2/php.ini - add the following line.

该包应该为您修改您的 INI 文件,但以防万一您需要自己编辑它,将其打开并进行以下修改 - 在 Ubuntu 上通常位于 /etc/php5/apache2/php.ini - 添加以下行。

zend_extension="/usr/lib/php5/20110331/xdebug.so"

That path might be a little different on your system - just make sure its a fully qualified path to the xdebug.so file on your machine. Also remember to comment out any references to the Zend Debugger - you can't run both at the same time.

该路径在您的系统上可能略有不同 - 只需确保它是您机器上 xdebug.so 文件的完全限定路径。还要记住注释掉对 Zend Debugger 的任何引用 - 您不能同时运行两者。

Now restart Apache.

现在重新启动Apache。

sudo /etc/init.d/apache2 restart

You may also need want enable html_errors. Search for html_errors in /etc/php5/apache2/php.ini and make sure it is set to On. A restart of Apache is also required.

您可能还需要启用 html_errors。在 /etc/php5/apache2/php.ini 中搜索 html_errors 并确保将其设置为 On。还需要重新启动 Apache。

html_errors = On

Double-check with phpinfo() to make sure that everything is installed properly - you may also want to set configurations for Xdebug in your php.ini file.

仔细检查 phpinfo() 以确保一切都安装正确 - 您可能还想在 php.ini 文件中为 Xdebug 设置配置。

回答by Parris Varney

sudo apt-get install php5-xdebug

回答by kronn

On a newer Ubuntu (at least on 14.04 LTS), I needed to activate the module as well. So, in total I did:

在较新的 Ubuntu(至少在 14.04 LTS 上)上,我也需要激活该模块。所以,我总共做了:

sudo apt-get install php5-xdebug
sudo php5enmod xdebug

After a restart of the server, xdebug was available.

重新启动服务器后,xdebug 可用。

回答by CIRCLE

This article was what helped me in Ubuntu 16.04 running PHP7:
Link to article

这篇文章对我在运行 PHP7 的 Ubuntu 16.04 中有所帮助:
文章链接

sudo apt-get install php-xdebug

回答by priyaranjan misra

::ubuntu 18.04, php7.2, apache2:: 1. First install xdebug using sudo apt-get install php-xdebug. 2. This will create file /etc/php/7.2/mods-available/xdebug.ini 3. You can run sudo phpenmod xdebug4. open xdebug.ini using sudo nano /etc/php/7.2/mods-available/xdebug.ini5. you can see only the line: zend_extension=xdebug.so 6. assuming running php apache on localhost and netbeans IDE, add following line to xdebug.ini

::ubuntu 18.04, php7.2, apache2:: 1. 首先使用sudo apt-get install php-xdebug. 2. 这将创建文件 /etc/php/7.2/mods-available/xdebug.ini 3. 您可以运行sudo phpenmod xdebug4. 打开 xdebug.ini 使用sudo nano /etc/php/7.2/mods-available/xdebug.ini5. 您只能看到该行:zend_extension=xdebug.so 6. 假设正在运行localhost 和 netbeans IDE 上的 php apache,将以下行添加到 xdebug.ini

xdebug.show_error_trace = 1
xdebug.idekey=netbeans-xdebug
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1

N.B: xdebug.idekey and xdebug.remote_port can be obtained from netbeans tools->optins->php->debug

注意:xdebug.idekey 和 xdebug.remote_port 可以从 netbeans tools->optins->php->debug 获得

回答by MESSIAH

Proper way to install XDEBUG for newest version of LAMPP:

为最新版本的 LAMPP 安装 XDEBUG 的正确方法:

  1. Download: XDEBUG latest versioncalled source.

  2. Extract file to any folder.

  3. Open this folder with terminal.

  4. Change X.X.Xto Your actually version of php

  5. Execute the following commands in your terminal.

    /opt/lampp/bin/phpize-X.X.X
    ./configure --with-php-config=/opt/lampp/bin/php-config-X.X.X
    make
    cp modules/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
    
  1. 下载:XDEBUG 最新版本叫源码。

  2. 将文件解压缩到任何文件夹。

  3. 用终端打开这个文件夹。

  4. XXX更改为您实际的php版本

  5. 在终端中执行以下命令。

    /opt/lampp/bin/phpize-X.X.X
    ./configure --with-php-config=/opt/lampp/bin/php-config-X.X.X
    make
    cp modules/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
    

Now we need edit file php.ini

现在我们需要编辑文件php.ini

  1. Open folder where is file php.iniin terminal:

    sudo nano ./php.ini
    
  2. Add to the end of file this:

    zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
    
  3. Open LAMPPfolder in terminal

  4. Now restart Apache.

    sudo ./xampp restart
    
  1. 在终端中打开文件php.ini所在的文件夹:

    sudo nano ./php.ini
    
  2. 添加到文件末尾:

    zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
    
  3. 在终端中打开LAMPP文件夹

  4. 现在重新启动Apache。

    sudo ./xampp restart
    

And now You can check phpinfo()to see XDEBUG is installed.

现在您可以检查phpinfo()以查看安装了 XDEBUG。

回答by bl00dshooter

Try compiling from source, that's what I do on my mac.

尝试从源代码编译,这就是我在 Mac 上所做的。

Otherwise, this might help you: http://ubuntuforums.org/showthread.php?t=525257

否则,这可能对您有所帮助:http: //ubuntuforums.org/showthread.php?t=525257