在 linux 上找不到 xdebug.so

Can't locate xdebug.so on linux

我在使用 php7 和 Apache2 在 ElementaryOS (Ubuntu 16.04.2) 上获取 xdebug 运行 时遇到了一些问题。

我用 sudo apt-get install php-xdebug 安装了它。安装没有报错。我添加了

xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1 ; Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true

/etc/php/7.0/apache2/php.ini

我还需要添加 xdebug.so 文件位置,例如 zend_extension="/path/to/xdebug.so"。但是,安装后我一直找不到xdebug.so。

有谁知道 xdebug.so 在哪里,或者自 php7.0 发布后说明是否发生了变化。大多数 instructions/help 似乎是针对 php5 在线的。

谢谢。

检查 xDebug 是否已安装。

php -m

运行 locate xdebug.so

Returns /usr/lib/php/20151012/xdebug.so 对我来说,但 20151012 将来可能会改变。

如果 locate 没有 return 任何东西或者你刚刚安装了 locate

,你必须执行 sudo updatedb

新版本只需添加xdebug文件名,例如:

zend_extension=xdebug.so

xdebug.default_enable = 1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
...

如果它不起作用,请使用 Linux 查找命令,如下所示:

find / -name "xdebug.so"

这个命令有什么作用?

  • 查找 = 只查找
  • / = 里面的所有目录/(全部)
  • -name "xdebug.so" = name 等于 xdebug.so

使用 phpinfo() 创建一个文件。找到项目 extension_dir。在那里您会看到 xdebug.so 所在的位置。我的是:

/usr/local/lib/php/extensions/no-debug-non-zts-20170718