Home » Php » macos – How to enable the memcached PHP extension after installing with homebrew?

macos – How to enable the memcached PHP extension after installing with homebrew?

Posted by: admin April 23, 2020 Leave a comment


I recently installed memcached with homebrew, I’m not entirely sure how to enable it on my PHP envirionment since I added extension=memcached.so in /etc/php.ini in Lion OS X.

Even I restarted apache too, nothing is still loaded.

If I call get_loaded_extensions(), I do not see memcached in the list, how can I enable it when installed from homebrew?


What I did in Terminal was:

$ brew install memcached

It installed just fine, now I went to /etc/php.ini and appended:


How to&Answers:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so'

That’s the information PHP is giving you, stick to it.

It’s either:

  • The file you have specified does not exists. Check your file-system.
  • The file you’ve specified can not be read by PHP, check the rights of the file.
  • The file you’ve specified is incompatible with your PHP binary. Check if you have compiled the right sources and compilation went well.


Install Memcached:

# lists all memcached related packages
brew search memcached

# install memcached as well as memcached extension for PHP
brew install memcached
brew install php54-memcached

# start memcached daemon with 24MB on port 11211 (default)
memcached -d -m 24 -p 11211

Add to your php.ini file to add:


Restart php or php5-fpm and your server. Verify:

php -i | grep memcached
# should show memcached version, etc.



brew install memcached
sudo pecl install memcached

Add this line to /etc/php.ini:

extension = memcached.so

If you are having trouble finding where it lives do

mdfind memcached.so -name
=> /usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so

Make sure it is running as a daemon (-d):

/usr/local/bin/memcached -d

Restart apache:

sudo apachectl restart


You’ll need to install libmemcached with homebrew, not just memcached. Do this:

brew install libmemcached

Then try recompiling your memcache PHP module. Should be good to go


First, install memcached library with:

sudo pecl install memcached

Then, add this line to /etc/php.ini:

extension = memcached.so

That’s it.


In Mac OS X El Capitan you can use

brew install homebrew/php/php55-memcached


You can install the memcache.so module the following way:

brew install memcached-php

(Note the above is currently broken if you don’t have the right Xcode version)

Then go to your php.ini file and add the following (Replace VERSION with the correct value):


Then restart apache:

sudo apachectl restart

If you can’t figure out which php.ini file is being used, try calling the phpinfo() command. It will tell you exactly which php.ini file it’s using.


It’s a 2016 so just try :

brew search memcached

You will find result and install what version of php you are using.

Don’t know if someone else still looking for this 🙂