通过 PECL 安装的 Redis PHP 扩展是否可以在 Mac M1 上运行?

Does the Redis PHP extension installed through PECL work on Mac M1?

Redis 服务器 运行 成功使用 Homebrew 和 brew services start redis。 PECL Redis 安装程序似乎与 sudo pecl install redis 一起工作,给出以下输出:

Build process completed successfully
Installing '/opt/homebrew/Cellar/php@7.4/7.4.28/pecl/20190902/redis.so'
install ok: channel://pecl.php.net/redis-5.3.7
Extension redis enabled in php.ini

如果我使用 php --ini,这是输出:

Warning: PHP Startup: Unable to load dynamic library 'redis.so' (tried: /opt/homebrew/lib/php/pecl/20190902/redis.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/redis.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/redis.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/redis.so' (no such file), '/usr/lib/redis.so' (no such file)), /opt/homebrew/lib/php/pecl/20190902/redis.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/redis.so.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/redis.so.so' (no such file), '/usr/local/lib/redis.so.so' (no such file), '/usr/lib/redis.so.so' (no such file))) in Unknown on line 0

redis.so 库位于 /opt/homebrew/lib/php/pecl/20190902。

有没有办法让这个库在 Mac M1 上工作?

您可以 运行 peclarch 来确保架构是 arm64.

arch -arm64 sudo pecl install redis

或者,您可以使用我维护的酿造水龙头 (shivammathur/extensions)。

brew tap shivammathur/extensions
brew install redis@7.4