Install memcache.so for PHP 5.6
1. Install memcached
$ brew install memcached
2. Download php source code
http://www.php.net/downloads.php
3. Copy source code to the folder /Applications/MAMP/bin/php/{php version}/include/php
e.g.) /Applications/MAMP/bin/php/php5.6.10/include/php
4. Install libiconv
$ brew install homebrew/dupes/libiconv
5. Execute configure in php source folder
$ cd /Applications/MAMP/bin/php/php5.6.10/include/php $ ./configure --with-iconv=/usr/local/Cellar/libiconv/1.14/
6. Install zlib
$ brew install zlib
7. Create link file for zlib
$ ln -s /usr/local/Cellar/zlib/1.2.8/include/* /usr/local/include $ ln -s /usr/local/Cellar/zlib/1.2.8/lib/* /usr/local/lib
8. Use pecl to install memcache
$ /Applications/MAMP/bin/php/php5.6.10/bin/pecl install memcache
9. Go to MAMP Pro -> File -> Edit Template -> PHP -> PHP 5.6.10
Add following lines to end of file
[memcache] extension=memcache.so
10. Restart services in MAMP
Install memcache.so for PHP 7.0
1. Re-install pkg-config (if get pkg-config error)
$ brew reinstall pkg-config
2. Download php.memcached and create memcache.so
$ cd /Applications/MAMP/bin/php/php7.0.8/include/php/ext $ wget http://pecl.php.net/get/memcache-3.0.8.tgz $ tar xf memcache-3.0.8.tgz $ cd memcache-3.0.8 $ /Applications/MAMP/bin/php/php7.0.8/bin/phpize
9. Go to MAMP Pro -> File -> Edit Template -> PHP -> PHP 5.7.08
Add following lines to end of file
[memcache] extension=memcached.so
Note:
To use cache memcache in Yii2 + PHP7+, then set cache configuration as below:
<?php $config = [ ... 'components' => [ 'cache' => [ 'class' => 'yii\caching\MemCache', // Use this to use memcache 'useMemcached' => true, 'servers' => [ [ 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 100, ], ], ], ], ... ];
Reference:
Hi Chris
I have a different path in my 3.5 MAMP PRO path is
Mamp/bin/php/php_version/
and for each php_version the sub folders
-> bin
-> modules
-> lib
-> conf
For whitch version is your how to?
Many thanks
Hi @eddie,
The working folder for phpnize was ” /Applications/MAMP/bin/php/php7.0.8/include/php/ext”.
If you would like to install different PHP version, then it would be “/Applications/MAMP/bin/php/{YOUR VERSION OF PHP}/include/php/ext”
– Chris
Is there an update for php 7.4 mamp?