首页 > 解决方案 > 在 Apple Silicon M1 下安装/重建 Xdebug 时出现问题

问题描述

无法在 Big Sur 下的新 Apple Silicon M1 下安装 XDebug - 使用pecl install xdebug并运行后php --ini出现以下错误:

PHP Warning:  Failed loading Zend extension 'xdebug.so' (tried: /opt/homebrew/lib/php/pecl/20190902/xdebug.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so, 9): no suitable image found.  Did find:
        /opt/homebrew/lib/php/pecl/20190902/xdebug.so: mach-o, but wrong architecture
        /opt/homebrew/lib/php/pecl/20190902/xdebug.so: stat() failed with errno=22), /opt/homebrew/lib/php/pecl/20190902/xdebug.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so.so, 9): image not found)) in Unknown on line 0

Warning: Failed loading Zend extension 'xdebug.so' (tried: /opt/homebrew/lib/php/pecl/20190902/xdebug.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so, 9): no suitable image found.  Did find:
        /opt/homebrew/lib/php/pecl/20190902/xdebug.so: mach-o, but wrong architecture
        /opt/homebrew/lib/php/pecl/20190902/xdebug.so: stat() failed with errno=22), /opt/homebrew/lib/php/pecl/20190902/xdebug.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so.so, 9): image not found)) in Unknown on line 0

我尝试从源代码(git clone git://github.com/xdebug/xdebug.git)重新编译 xdebug,结果相同。我可以config.m4在重新编译 xdebug 时强制使用正确的架构吗?- 还有其他建议吗?

标签: xdebugapple-silicon

解决方案


我需要指定架构。它适用于:

arch -arm64 sudo pecl install xdebug

推荐阅读