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

MacMac picture MacMac · Oct 22, 2011 · Viewed 93.3k times · Source

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?

EDIT:

What I did in Terminal was:

$ brew install memcached

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

extension=memcached.so

Answer

aleemb picture aleemb · Dec 8, 2013

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:

extension=memcached.so

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

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