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.
sudo pecl install memcache
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
sudo apachectl restart
7 thoughts on “PHP memcache extension on OSX Lion”
[…] PHP to use the new extension, if you are unsure on how to do this you can follow the end of yesterdays post – but dont forget to use memcached instead of memcache. Share this: Filed under: Mac, PECL, PHP […]
pecl is not known by mac lion. how to make it work? Thanks before.
— agus kianto
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.
Thanks for the information – worked flawlessly for me here (clean Lion install, 10.7.4)
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
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
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
You are missing autoconf, there are a few ways to get it:
– Brew or
– Compile from source
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