Tag Archives: macosx

Install memcached PHP extension on OS X Snow Leopard

Memories

memcached is a very useful memory object caching system, which can be used to increase the performance of your dynamic scripts by caching database calls.

This guide will explain how to install the memcached system, including the PHP extension, on Mac OS X 10.6.

Xcode

The Xcode package installs the necessary versions of tools like autoconf which is needed during the PHP extension compilation process. Make sure you have Xcode 3.2 installed; the install package is available on the Snow Leopard install DVD under the “Optional Installs” folder.

libevent

libevent is a pre-requisite for memcached.

  • cd /tmp; curl -O http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz
  • tar zxvf libevent-1.4.12-stable.tar.gz
  • cd libevent-1.4.12-stable
  • ./configure; make
  • sudo make install

memcached

memcached is the daemon responsible for actually storing and retrieving arbitrary objects for your applications.

  • cd /tmp; curl -O http://memcached.googlecode.com/files/memcached-1.4.1.tar.gz
  • tar zxvf memcached-1.4.1.tar.gz
  • cd memcached-1.4.1
  • ./configure; make
  • sudo make install

libmemcached

libmemcached is the shared library that will allow clients, in this case PHP, access the memcached daemon.

  • Download libmemcached, move to /tmp and unpack
  • cd libmemcached-0.31
  • ./configure; make
  • sudo make install

php extension

Now we are ready to prepare the PHP extension to memcached, which is available from pecl.

  • cd /tmp; pecl download memcached
  • gzip -d < memcached-1.0.0.tgz | tar -xvf -
  • cd memcached-1.0.0; phpize

You should see output similar to the following:

Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

  • ./configure; make
  • sudo make install

On a successful install, you will get the following message:

Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20090626/

Modify your php.ini configuration file and make sure you have the following line included:

extension = memcached.so

You can then restart your Apache server:

  • sudo apachectl restart

to make the memcached functionality available in your scripts.

memcached php extension

References

Glen Scott

I’m a freelance software developer with 18 years’ professional experience in web development. I specialise in creating tailor-made, web-based systems that can help your business run like clockwork. I am the Managing Director of Yellow Square Development.

More Posts

Follow Me:
TwitterFacebookLinkedIn