How to enable the memcached PHP extension after installing with homebrew?
Solution 1
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.
Solution 2
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.
Solution 3
Install:
brew install memcached
OR
sudo pecl install memcached
Add this line to /etc/php.ini:
extension = memcached.so
OR
extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/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
Solution 4
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
Solution 5
First, install memcached library with:
sudo pecl install memcached
Then, add this line to /etc/php.ini
:
extension = memcached.so
That's it.
Comments
-
MacMac almost 3 years
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
-
MacMac over 12 yearsI don't know how to give you more information, check my edit.
-
hakre over 12 yearsHave you installed php with homebrew as well? And is the .so file inside the directory PHP expects it to be?
-
MacMac over 12 yearsNo, I'm using the PHP that came with Lion OS X by default. There is no
memcached.so
in the directory. -
MacMac over 12 yearsThere is actually no
memcached.so
around my MacBook, I tried searching with thefind
command and didn't find it at all. -
hakre over 12 yearsThen first install the memcache PHP extension (next to the server). Without the actual binary of the extension, it's obvious, that it does not work, isn't it?
-
MacMac over 12 yearsHmm. I fixed the problem, I first installed libmemcached via homebrew then installed memcached with pecl.
-
Brendon Muir about 12 yearsThis answers your question better. You think you've installed the php extension for memcached but have only installed memcached itself.
-
yegor256 almost 12 years
brew install memcached-php
givesError: No available formula for memcached-php
-
Evan over 11 yearswhat is the correct version of xcode needed for this? will it work with 3.2.6?
-
Brian Noah over 11 yearsInstalled and got error about autoconf. Next person who reads this, install autoconf by using brew install autoconf
-
JordanC about 11 yearsTry: brew install php54-memcached (or php53 if you are on 5.3)
-
geoidesic over 10 yearsAnd how would you "recompile your memcache PHP module" then?
-
msanford over 10 yearsTap:
brew tap homebrew/dupes;brew tap josegonzalez/homebrew-php
(see github.com/josegonzalez/homebrew-php ) thenbrew install php55-memcached
(or whatever version you're using). -
Dave Kiss over 9 yearsThis was what I was missing:
brew install php55-memcached
-
Dave Kiss over 9 years
brew reinstall memcached
-
henrijs over 9 yearsIt now seems as adding "extension=memcached.so" is not needed as php on startup says "Additional .ini files parsed => /usr/local/etc/php/5.4/conf.d/ext-memcached.ini" which has that line in it.
-
phpguru over 8 yearsIn fact libmemcached was my issue as well. I had already installed it, so when I tried
brew install libmemcached
brew said Warning: libmemcached-1.0.18_1 already installed, it's just not linked. So I ran brew link libmemcached and then there was a permissions issue on /usr/local/include so I chown -R that folder to my user and then brew link ran fine, and then the extension worked, the error went away and my site loaded just fine. -
user269867 about 7 yearswhat is autoconf?
-
user269867 about 7 yearsThe above installation works for CLI but with Apache it is not working. Any idea how to fix for apache I am trying to add additional ini in apache but not effective either. Any help is much appreciated.
-
jmontross over 6 years@user269867 - gnu.org/software/autoconf/manual/autoconf.html