Knowledge
Install PHP memcached extension on macOS
#Development
Published by Mark van Eijk on March 17, 2023 · 1 minute read
Install using Homebrew and PECL
If you have PHP installed using Homebrew, you previously could also install PHP extensions using brew
itself. But things have changed, and you need to use pecl
to install additional extensions.
When you need to install memcached
, you need to install this including the dependencies zlib
and libmemcached
:
brew install memcached libmemcached zlib pkg-config
Then you can initiate the install via pecl
:
pecl install memcached
This will ask multiple questions, where you will only need to answer the question about the path of zlib:
zlib directory [no] :
This path depends on the processor of your Mac, there's a difference between Apple silicon machines on Mac Intel. The path is per type of machine:
ZLIB path
# On Apple Silicon
/opt/homebrew/opt/zlib
# On Mac Intel
/usr/local/opt/zlib
When given this path, the pecl
install should complete successfully.
Subscribe to our newsletter
Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!