Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

The Redis server is running successfully using Homebrew with brew services start redis. The PECL Redis installer appears to work with sudo pecl install redis , giving the following output:

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

If I use php --ini, this is the output:

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

The redis.so library is in /opt/homebrew/lib/php/pecl/20190902.

Is there any way to get this library working on Mac M1?

like image 240
Blue5hift Avatar asked Nov 02 '25 01:11

Blue5hift


2 Answers

You can run pecl with arch to ensure that the architecture is arm64.

arch -arm64 sudo pecl install redis

Alternatively, you can use a brew tap I maintain (shivammathur/extensions).

brew tap shivammathur/extensions
brew install [email protected]
like image 177
Shivam Mathur Avatar answered Nov 03 '25 16:11

Shivam Mathur


I have done the same like accepted answer

arch -arm64 sudo pecl install redis

But that didn't work for me immediately. I needed to reinstall redis.

pecl uninstall redis

pecl install redis

like image 42
Martin54 Avatar answered Nov 03 '25 15:11

Martin54



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!