【问题标题】:Problem xdebug for PHP 7.3.12-1+ubuntu16.04.1PHP 7.3.12-1+ubuntu16.04.1 的问题 xdebug
【发布时间】:2019-12-01 00:05:18
【问题描述】:

我是根据https://xdebug.org/docs/install 从源代码构建的,因为 pecl/pearl 坏了:

pecl install xdebug
downloading xdebug-2.8.0.tgz ...
Starting to download xdebug-2.8.0.tgz (238,122 bytes)
.................................................done: 238,122 bytes
PHP Fatal error:  Cannot use result of built-in function in write context in /usr/share/php/Archive/Tar.php on line 639

构建后,lib 位于/usr/lib/php/20180731/xdebug.so。 我加了/etc/php/7.3/apache2/php.ini:

[opcache]
...
[xdebug]
zend_extension=~"/usr/lib/php/20180731/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

我重启了 apache:service apache2 restart
我检查了service apache2 status

当我运行php -m 时,它会显示

[Zend Modules]
Zend OPcache

但没有 XDebug。 php --version 的输出是:

PHP 7.3.12-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Nov 28 2019 07:36:56) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.12-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
root@HAL:/home/richard#

也没有 XDebug。 所以现在我无法让 XDebug 与 Visual Studio Code 一起工作。 有任何想法吗?非常感谢

【问题讨论】:

  • @jww:感谢格式和其他更改,例如插入“I”和“When”
  • 你已经有了“sury”包repos,你为什么不从那里使用Xdebug?
  • 因为我不知道“sury”是做什么的?无论如何,我想我解决了这个问题。感谢您的帮助。
  • launchpad.net/~ondrej -- 您可以找到各种包含和用于多个操作系统的各种 PHP 版本的软件包。你的 PHP 版本字符串是“7.3.12-1+ubuntu16.04.1+deb.sury.org+1”,所以你应该准备好了。
  • 我的这些断点现在可以与我构建的 *.so 文件一起使用。你的方法也可以工作(还没有测试过),但是我需要找出这个 sury 包的作用以及如何在 Visual Studio Code 中使用它。无论如何,我现在将继续我的实际工作,调试器只是一个工具,一个达到目的的手段。

标签: php linux debugging ubuntu-16.04


【解决方案1】:

像往常一样,这是一个愚蠢的用户(我)错误。 我在 Downloads 文件夹中解压了 XDebug 的源代码。 然后它在 ~/Downloads/xdebug-2.8.0/modules 中构建,我还在 ~/Downloads/xdebug-2.8.0/.libs 中找到了一个副本。

所以,首先我有一个指向我的主目录的路径,以 ~ 开头。 我发现 *.so 文件也已复制到 /usr/lib/php/20180731/xdebug.so,因为我在这里阅读了 https://xdebug.org/docs/install

zend_extension="/usr/local/php/modules/xdebug.so"

我将其与我自己的系统进行了比较。 现在,这是一个大错误:在编辑路径时 “/usr/lib/php/20180731/xdebug.so”,我忘了去掉前导~!!!

因此无法加载模块。一条错误消息说它找不到指定的路径/文件会很好,因为人类确实会犯错误。也许某个日志文件中隐藏了这样的错误消息,我没有检查。至少有一个读取日志文件的警告会很棒。

删除这个波浪号并重新启动服务器后,phpinfo 显示 XDebug 模块已加载。

对不起,浪费了您的时间。 我想这里的许多问题都是由无知和愚蠢引起的,这表明我并没有摆脱这些 ;-)

也许是在恳求我自己解决了这个问题。

更新了 php.ini 中的部分:

[xdebug]
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart = 1

一些取自The xdebug extension is not loaded

我希望这对其他人有帮助。

【讨论】:

    【解决方案2】:

    对于那些使用 XDebug 并因此可能正在制作网站的人: 我做了一个这样的脚本(学分都给 Thomas Ward):

    #!/bin/bash
    
    # https://askubuntu.com/questions/767504/permissions-problems-with-var-www-html-and-my-own-home-directory-for-a-website
    chgrp -R www-data /var/www/html
    find /var/www/html -type d -exec chmod g+rx {} +
    find /var/www/html -type f -exec chmod g+r {} +
    
    chmod -R o-rwx /var/www/html/
    
    chown -R richard /var/www/html/
    find /var/www/html -type d -exec chmod u+rwx {} +
    find /var/www/html -type f -exec chmod u+rw {} +
    
    # This sets the "set gid" bit for the group on the directories.
    # Files and folders created inside these directories will always have www-data as the group, 
    # permitting the web server access
    find /var/www/html -type d -exec chmod g+s {} +
    

    运行后(通常只运行一次),Visual Studio Code 可以在 /var/www/html 下写入文件

    现在,当 Visual Code 想要保存 Web 项目中更改的文件时,不再提示您按 OK 并填写 root 密码。

    您当然需要填写自己的用户名。 在您的情况下,路径 /var/www/html 可能是 /opt/lampp/htdocs

    我希望这对其他人有所帮助。

    【讨论】:

      猜你喜欢
      • 2011-01-15
      • 2015-10-18
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多