Using memcached with stock OS X Apache
I wanted to use memcached but didn't want to compile all the dependencies by hand and wanted to use the stock version of Apache that ships with OS X so I cobbled together the following instructions.
- Install MacPorts
- Use MacPorts to install memcached:
sudo port install memcached - Use
peclto download the latest version ofmemcachedand uncompress it:
cd /tmp
pecl download memcached
tar xvzf memcached-*.tgz - Build the extension using MacPort's version of
libmemcached(which was installed as a dependency ofmemcached):
cd memcached-*/
phpize
./configure --with-libmemcached-dir=/opt/local/
sudo make install - Enable it by editing
php.iniand adding the following line:
extension=memcached.so - Restart Apache:
sudo apachectl graceful
References:
MAMP + memcache = drilling a screw in my eye
Here's yet another blog post to document something so stupid that I hope to never do it again, but know I will. I spent the better part of the afternoon trying to get the PECL memcache extension working with the PHP 5.2 part of a MAMP installation and finally managed to get it working.
Install XCode.
Open up a terminal and become the root user:
sudo suMake all the MAMP PHP binaries executable:
chmod u+x /Applications/MAMP/bin/php5.2/bin/p*Now get the memcache source, compile it and copy the library into PHP's extensions directory:
cd /tmp
wget http://pecl.php.net/get/memcache-2.2.5.tgz
tar -zxvf memcache-2.2.5.tgz
cd memcached-2.2.5
/Applications/MAMP/bin/php5.2/bin/phpize
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' ./configure
make
cp modules/memcache.so /Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20060613/Tell PHP to load the memcache extension:
echo 'extension=memcache.so' > /Applications/MAMP/conf/php5.2/php.iniSources:
http://www.php.net/manual/en/memcache.installation.php#95063
http://blog.m-schmidt.eu/2010/03/30/develop-memcached-web-apps-with-xamp...