Ubuntu 上可以使用 xdebug 吗?

发布于 2024-10-28 05:03:44 字数 88 浏览 7 评论 0原文

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

毁梦 2024-11-04 05:03:44

在终端中执行以下命令。

下载 Xdebug - 如果您的计算机上尚未安装 PHP5,则需要遵循备用说明。

sudo apt-get install php5-xdebug

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

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

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

现在重新启动 Apache。

sudo /etc/init.d/apache2 restart

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

html_errors = On

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

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.

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.

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.

Now restart 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 = 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.

紫竹語嫣☆ 2024-11-04 05:03:44
sudo apt-get install php5-xdebug
sudo apt-get install php5-xdebug
有深☉意 2024-11-04 05:03:44

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

sudo apt-get install php5-xdebug
sudo php5enmod xdebug

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

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

sudo apt-get install php5-xdebug
sudo php5enmod xdebug

After a restart of the server, xdebug was available.

走走停停 2024-11-04 05:03:44

这篇文章对我在运行 PHP7 的 Ubuntu 16.04 中提供了帮助:
文章链接

sudo apt-get install php-xdebug

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

sudo apt-get install php-xdebug
_蜘蛛 2024-11-04 05:03:44

::ubuntu 18.04、php7.2、apache2::
1. 首先使用 sudo apt-get install php-xdebug 安装 xdebug。
2. 这将创建文件 /etc/php/7.2/mods-available/xdebug.ini
3.您可以运行sudo phpenmod xdebug
4.使用sudo nano /etc/php/7.2/mods-available/xdebug.ini打开xdebug.ini
5.你只能看到这一行: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

注意: xdebug.idekey 和 xdebug.remote_port 可以从 netbeans 工具->optins->php->debug 获取

::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 xdebug
4. open xdebug.ini using sudo nano /etc/php/7.2/mods-available/xdebug.ini
5. 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

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

夜深人未静 2024-11-04 05:03:44

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

  1. 下载:XDEBUG 最新版本称为源。

  2. 将文件提取到任意文件夹。

  3. 使用终端打开此文件夹。

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

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

    <代码>/opt/lampp/bin/phpize-XXX
    ./configure --with-php-config=/opt/lampp/bin/php-config-XXX
    制作
    cp 模块/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
    

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

  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
    

现在您可以检查 phpinfo() 以查看 XDEBUG 是否已安装。

Proper way to install XDEBUG for newest version of LAMPP:

  1. Download: XDEBUG latest version called source.

  2. Extract file to any folder.

  3. Open this folder with terminal.

  4. Change X.X.X to 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
    

Now we need edit file php.ini

  1. Open folder where is file php.ini in 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 LAMPP folder in terminal

  4. Now restart Apache.

    sudo ./xampp restart
    

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

太阳哥哥 2024-11-04 05:03:44

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

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

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文