加载 xdebug.so 失败:未定义符号:gc_globals

tom*_*her 6 php installation xdebug

我尝试在我的计算机上安装 PHP 的 Xdebug 扩展(Linux Mint,PHP 版本 7.3.6)。

我已按照Xdebug 向导页面的说明进行操作。完成后,我在终端中运行了以下命令:

php --version
Run Code Online (Sandbox Code Playgroud)

它向我显示了我的 PHP 版本,但也显示了以下警告:

加载失败 /usr/lib/php/20180731/xdebug.so: /usr/lib/php/20180731/xdebug.so: 未定义符号: gc_globals

调用 phpinfo() 时,Xdebug 也未列为已启用的扩展。你能帮忙吗,我的 Xdebug 安装哪里有问题?

我已经使用向导页面中的以下步骤安装了 Xdebug:

• Download xdebug-2.7.2.tgz
• Install the pre-requisites for compiling PHP extensions.
• On your Ubuntu system, install them with: apt-get install php-dev autoconf automake
• Unpack the downloaded file with tar -xvzf xdebug-2.7.2.tgz
• Run: cd xdebug-2.7.2
• Run: phpize (See the FAQ if you don't have phpize).
• 
• As part of its output it should show:
• 
• Configuring for:
• ...
• Zend Module Api No:      20180731
• Zend Extension Api No:   320180731
• If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
• 
• Run: ./configure
• Run: make
• Run: cp modules/xdebug.so /usr/lib/php/20180731
• Edit /etc/php/7.3/cli/php.ini and add the line
• zend_extension = /usr/lib/php/20180731/xdebug.so
Run Code Online (Sandbox Code Playgroud)

小智 2

有这个问题,就我而言,它是由于安装了不同版本的 PHP 而发生的。CLI 的 PHP 版本为 7.2,FPM 的版本为 7.3。因此,在 7.3 服务器上使用 7.2 的 xdebug 安装版本。

检查php -v终端中使用的 CLI 版本。

要检查 FPM 版本,请使用phpinfo();页面或php-fpm7.2 -v在终端中运行(由于二进制名称中的版本,这有点毫无意义)。

我的解决方案是删除与 php 7.3 相关的软件包。

但是您可以通过其他方式解决问题,例如安装正确版本的 xdebug 或降级 php-fpm。