Daily Archives: December 16, 2010

How to Install Memcache on Mac OS X

Hopefully I’ll save somebody days of work here. If you’re on a mac, unfortunately you can’t just run “pecl install memcache” (well you can, but it won’t work). I’m using Zend Server CE, which is a 32 bit application and if you run the above command to install from pecl, you’ll get a 64 bit version installed. Oh, and let’s be clear, we’re working with Memcache and not Memcached (they are very similar, but different).

OK, how to make it work. Open terminal and run the following commands –

  1. cd /tmp
  2. pecl download memcache
  3. tar xzf memcache-2.2.6.tgz (or whatever file and version you downloaded)
  4. cd memcache-2.2.6
  5. OK, here is a tricky one. Copy this line and change the path on the end to the location of your phpize executable and paste into terminal.

    ./configure MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ LDFLAGS=’-O3 -arch i386 -arch x86_64′ CXXFLAGS=’-O3 -fno-common -arch i386 -arch x86_64′ –with-php-config=/usr/local/zend/bin/php-config

  6. make
  7. make install

Restart apache and you should be good to go.