PHP memcache extension on OSX Lion

Today I needed the PHP memcache extension on my Mac OSX Lion 10.7.3 development machine for a project I’m working on. I was pleased to find out that this was a nice and easy one to get up and running.

Open up a terminal window and run the command below, this will tell PECL to download, build and install the extension.

Now that the extension is installed on your system, you need to enable it in your PHP configuration file. On a standard system the php.ini file can be found at /etc/php.ini. Open the file and scroll down to the extensions section, at the bottom of this section add the line extension=memcache.so and then save and close the file.

After that, all that is required is for you to restart Apache and enjoy your new extension

7 thoughts on “PHP memcache extension on OSX Lion

    • Andy Hunt

      Did you do an upgrade or clean install of Lion? Also are you using the PHP that comes built in or something like MAMP?

      I suggest you first try upgrading pear using ‘sudo pear upgrade pear’, then try the pecl command again.

  • need help

    tried above and get
    downloading memcache-2.2.6.tgz …
    Starting to download memcache-2.2.6.tgz (35,957 bytes)
    ……….done: 35,957 bytes
    11 source files, building
    running: phpize
    grep: /usr/include/php/main/php.h: No such file or directory
    grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
    grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
    Configuring for:
    PHP Api Version:
    Zend Module Api No:
    Zend Extension Api No:
    Cannot find autoconf. Please check your autoconf installation and the
    $PHP_AUTOCONF environment variable. Then, rerun this script.

    ERROR: `phpize’ failed

    • Andy Hunt

      You are missing autoconf, there are a few ways to get it:
      – Macports
      – Brew or
      – Compile from source

  • Elliot

    Hello,

    I’ve been getting the following error when I start up apache. I’m on Lion and I tried it with Xcode 4.5 and 4.2. I’ve also tried adding configure flags.

    PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so’ – dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so, 9): Symbol not found: _zend_new_interned_string\n Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so\n Expected in: flat namespace\n in /usr/lib/php/extensions/no-debug-non-zts-20090626/memcache.so in Unknown on line 0

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: