Finally got memcache working!
I am compiling the steps here in case I need to do it again.
First install libevent. This is a dependency to memcached, so need to get it.
cd /tmp
curl -OL https://github.com/downloads/libevent/libevent/libevent-2.0.17-stable.tar.gz
tar -xvzf libevent-2.0.17-stable.tar.gz
cd libevent-2.0.17-stable*
./configure
make
sudo make install
Then install memcached.
# Compile memcached utility
cd /tmp
curl -O http://memcached.googlecode.com/files/memcached-1.4.13.tar.gz
tar -xvzf memcached-1.4.13.tar.gz
cd memcached-1.4.13*
./configure
make
sudo make install
At this point, if everything goes well, the memcache daemon should be ready to run. You can try the following to see if memcached returns anything to you.
memcached -d -m 24 -p 11211
telnet localhost 11211
stats
quit
When you run memcached -d -m 24 -p 11211, you are assigning 24Mb ram for memcache to use, and using the port 11211, which is the default port for memcache. The -d runs memcache as a daemon.
After you run stats, you should see some stats returned on your screen. If so, that means memcache is running fine now.
Next step is to make sure php can talk to memcache.
Download the php extension to memcached from this link: http://pecl.php.net/package/memcache. I recommend getting the stable version, 2.2.6 as of June 2012.
After uncompressing it, do phpize. If you get an error on not having autoconf, install it with brew. See my other tutorial on how to do that.
gzip -d < memcache-2.2.6.tgz | tar -xvf -
cd memcache-2.2.6
phpize
After phpize gives you your php version info, do the usual compile and install:
./configure
make
sudo make install
Double check that the memcache.so file is in your php include directory.
ls /usr/lib/php/extensions/no-debug-non-zts-20090626/
It should be there… if not, you can manually copy the file yourself. It’s located under the “modules” folder.
Now, modify your /etc/php.ini file to include this extension.
extension = memcache.so
Then finally, restart apache.
sudo apachectl restart
If everything goes well, your phpinfo() should give you a section on memcached, indicating memcached is loaded properly.
Congratulation! At this point php is ready to interact with memcache. But just how to do that in code? Let’s wait for my part 2 of this tutorial. ;)
Ref link: http://readystate4.com/2012/03/15/installing-memcached-on-os-x-10-7-3-lion-on-mamp/ http://www.glenscott.co.uk/blog/2009/08/30/install-memcached-php-extension-on-os-x-snow-leopard/ http://jamiecurle.co.uk/blog/memcached-on-osx-without-macports/