-
-
Save rpersaud/1560910 to your computer and use it in GitHub Desktop.
@see http://www.re-cycledair.com/installing-memcache-on-mamp | |
Step 1: Install XCode | |
Step 2: Make the MAMP PHP binary files executable | |
sudo chmod +xrw /Applications/MAMP/bin/php5.3/bin/p* | |
Step 3: Get the Memcache extension source | |
cd ~ | |
wget http://pecl.php.net/get/memcache-2.2.5.tgz | |
tar -zxvf memcache-2.2.5.tgz | |
cd memcache-2.2.5 | |
Step 4: PHPize the Memcache extension files | |
/Applications/MAMP/bin/php5.3/bin/phpize | |
Step 5: Compile the Memcache extension | |
./configure | |
make | |
*If this configure doesnt work, and you're on a snow leopard arch, try this - | |
CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure | |
make | |
sudo make install | |
Step 6: Add the extension to the PHP.ini file | |
Add the following to the end of your PHP 5.3 ini file via the MAMP file menu. | |
extension=memcache.so | |
Step 7: Copy the memcache extension to the PHP extension folder | |
cp modules/memcache.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-[yourtimestamp]/ |
<?php | |
$memcache = new Memcache; | |
$memcache->connect('localhost', 11211) or die ("Could not connect"); | |
$version = $memcache->getVersion(); | |
echo "Server's version: ".$version."<br/>\n"; | |
$tmp_object = new stdClass; | |
$tmp_object->str_attr = 'test'; | |
$tmp_object->int_attr = 123; | |
$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server"); | |
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n"; | |
$get_result = $memcache->get('key'); | |
echo "Data from the cache:<br/>\n"; | |
var_dump($get_result); | |
?> |
Mamp is not reflecting memcache enabled in phpinfo. APC, Xcache display, however.
PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/memcache.so' - dlopen(/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/memcache.so, 9): no suitable image found. Did find:
/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/memcache.so: mach-o, but wrong architecture in Unknown on line 0
Potential command to run-
phpize
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure
make
sudo make install
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 --with-php-config=/Applications/MAMP/bin/php5.3/bin/php-config? Unable to get it to work
Got memcache to work via this links help - http://bit.ly/wgVm4m
phpize
CFLAGS=-m32 CPPFLAGS=-m32 CCASFLAGS=-m32 ./configure
make
sudo make install
It was important not to ./configure with-php-config="/Applications/MAMP/..." that last parameter, killed it. This was for a 10.6.8 quad xeon processor arch - macosx snow leopard.
This is a great tutorial on using memcache - http://www.search-this.com/2007/07/24/an-introduction-to-memcached/
Got the php.net example to work by following this tutorial -
"One thing I experienced, re: start/stopping with MAMP. I found I was getting Connection Refused (61) errors in PHP, which were due to the memcached process not running at all.
I needed to make the following modifications to the startMemcached.sh script:
/usr/local/bin/memcached -m 24 -p 11211 -u user -d
- The full path needed to be added (alternately probably could do this with $PATH)
- Since MAMP was starting/stopping things as root, the -u user had to be added to tell it what user to impersonate (memcached won't run as root). Obviously "user" should be replaced with an actual user name..."
find the latest versions of memcache - http://pecl.php.net/package/memcache