Xdebug .so文件存在但还是报未找到

Xdebug .so file exists but still reported not found

这是/etc/php/7.2/cli/conf.d/20-xdebug.ini内容:

zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_autostart=off

这是我通过 运行 php:

得到的错误
PHP Warning:  Failed loading Zend extension 'xdebug.so' (tried: /usr/lib/php/20170718/xdebug.so (libc.musl-x86_64.so.1: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/xdebug.so.so (/usr/lib/php/20170718/xdebug.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

然而 /usr/lib/php/20170718/xdebug.so 存在并具有读取权限:

# ls -l /usr/lib/php/20170718/xdebug.so
-rw-r--r--. 1 root root 2078128 Jan 16 11:15 /usr/lib/php/20170718/xdebug.so

将扩展路径更改为完整路径也没有什么不同。

可能是什么原因?

参考下面的link,我认为它会像我一样解决你的问题 Installing Xdebug

在您的 xdebug.ini 文件中尝试此内容

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9000 
xdebug.show_error_trace = 1 <--- you can skip this
xdebug.remote_autostart = 0

似乎附带的 xdebug 模块已损坏,通过 apt 安装它解决了问题:

apt install php-xdebug

在通过apt安装之前,我也尝试并编译了很多次源代码,但每次我都得到同样的错误。然而确切的原因仍然未知。

我想您正在使用 mac,无法通过 /usr/include 访问 C 头文件。有几种方法可以解决这个问题,但自己编译可能是最好的方法。如果您不想关闭 SIP,我会推荐 https://bbqsoftwares.com/blog/xdebug-catalina