Tag Archives: snowleopard

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

Fix PHP timezone warnings in OS X Snow Leopard

The standard Mac install of PHP has always been somewhat quirky, and 10.6 is no exception. One of the most obvious issues occurs when attempting to use date/time functions. PHP 5.3 requires that the date.timezone setting is available. Without this, you will receive a warning similar to the following:

Warning: getdate() [function.getdate]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for 'BST/1.0/DST' instead in /Users/gscott/Sites/hello-world.php on line 9

The solution is to edit (or create, if it doesn’t exist) /private/etc/php.ini and make sure a setting exists for date.timezone. For example:

date.timezone = Europe/London

After making the change, restart Apache

sudo apachectl restart

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