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.
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. 😉
8 thoughts on “Installing memcache on osx for php”
Thanks for publishing this. Very helpful.
Finally I found a tut which works. Thank you for writing this.
On and off in the past two days, I was searching for a solution to install memcache to XAMPP, after googling many related posts, yours is the clearest I came across, I finally got memcache to work on XAMPP! Thanks for your help. 🙂
There are a few differences installing it to XAMPP then to MAMP. A few twists were needed.
I have seen this question posted on XAMPP forum quite a few times and I would like to post a tutorial there, may I have your permission to add the twist to your tutorial ?
Hey Rich, I am glad you found my post useful. 😉 Feel free to use any content from my post here. You could even write a new post (specific to XAMPP) and post your blog post link to my comment section here, whichever is more clear to the readers to follow the steps. =)
Thanks for sharing your thoughts on oral steroids
for Powerlifting. Regards
After looking into a number of the blog posts onn your weeb site, I seriously appreciate your way of
writing a blog. I book-marked it to myy bookmark website list
and will be checking back soon. Please check out my website as
well and tell me how you feel.