Install php-redis extension in Mac with Homebrew

Today I’ve been trying the Monica package and it requires the redis.so extension.

I started installing using PECL binary for the PHP version I’m using:

/usr/local/opt/php\@7.3/bin/pecl install redis
Build process completed successfully
Installing '/usr/local/Cellar/php@7.3/7.3.18/pecl/20180731/redis.so'
install ok: channel://pecl.php.net/redis-5.2.2
Extension redis enabled in php.ini

That’s it, this should be copying redis.so to the loading modules directory.

Troubleshooting

Library not loaded: libreadline.7.dylib

If you see this error when running the PECL to install redis:

dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
Referenced from: /usr/local/bin/awk
Reason: image not found
./config.status: line 764: 73034 Abort trap: 6 $AWK -f "$ac_tmp/defines.awk" '/private/tmp/pear/temp/redis/config.h.in'
config.status: error: could not create config.h
ERROR: `/private/tmp/pear/temp/redis/configure --with-php-config=/usr/local/opt/php@7.3/bin/php-config --enable-redis-igbinary=no --enable-redis-lzf=no --enable-redis-zstd=no' failed
You can solve it by symlinking this libreadline.7.dylib library:
cd /usr/local/opt/readline/lib
ln -s libreadline.8.0.dylib libreadline.7.dylib

Source: https://stackoverflow.com/a/54287994/12191185

Leave a Comment