How to install redis (and other extensions) on macOS

I wanted to test my plugin’s Redis queue locally, so I had to find a way of installing Redis in Local.

Prerequisite

  1. shivammathur/php, the same PHP version as the one you are running in Local:
brew tap shivammathur/php
brew install shivammathur/php/php@8.3
brew link --overwrite --force shivammathur/php/php@8.3
  1. Install Redis and extensions needed by Redis from shivammathur/extensions:
brew tap shivammathur/extensions
brew install shivammathur/extensions/msgpack@8.3
brew install shivammathur/extensions/igbinary@8.3
brew install shivammathur/extensions/redis@8.3

Adding the extension to Local

  1. Locate the Local extension folder
    Mine was in ~/Library/Application Support/Local/lightning-services/php-8.3.23+0/bin/darwin-arm64/lib/php/extensions/no-debug-non-zts-20230831
  2. Copy the shivammathur extensions to Local extension folder
    The shivammathur extensions are in /opt/homebrew/Cellar/<name>@<PHP version>/<extension version>/<filename>.so eg:
/opt/homebrew/Cellar/msgpack@8.3/3.0.0/msgpack.so
/opt/homebrew/Cellar/igbinary@8.3/3.2.16/igbinary.so
/opt/homebrew/Cellar/redis@8.3/6.2.0/redis.so
  1. In Local extension folder, sign the extensions for macOS security:
codesign -s - -f msgpack.so
codesign -s - -f igbinary.so
codesign -s - -f redis.so

Load the extension

  1. Open <Your Site>/conf/php/php.ini.hbs, in your favorite editor, and add the following at the end of the file:
[ini]
extension = {{extensionsDir}}/msgpack.so
extension = {{extensionsDir}}/igbinary.so
extension = {{extensionsDir}}/redis.so
  1. Restart Local

Test

  • In the Site Shell, test if Redis was loaded: php -m | grep redis

NOTE: This should work for other extensions :slight_smile:
NOTE 2: This might also work on Linux. shivammathur/php supports the following operating systems:

Operating System Architecture
Linux x86_64, arm64
macOS Sonoma x86_64, arm64
macOS Sequoia x86_64, arm64
macOS Tahoe x86_64, arm64
2 Likes

Btw, I followed the guide by @nickc when I configured my Redis server. Redis server for Local? - #7 by nickc. It works like a charm :slight_smile:

2 Likes

This is awesome! Thanks for writing it up!

1 Like