macOS 使用MAMP环境安装扩展

I’m using PHP 5.6.10, and trying to install the memcache extension. You can adapt this to other PHP versions and to other extensions, of course :smile:

  • Download the version of PHP you’re using from php.net.
  • At /Applications/MAMP/bin/php/php5.6.10, create a directory named include.
  • Inside /Applications/MAMP/bin/php/php5.6.10/include (your newly created folder), untar the php file you downloaded from php.net.
  • For me, it produced a folder named “php-5.6.10”. Rename it to “php”. Now you’ll have this structure: /Applications/MAMP/bin/php/php5.6.10/include/php
  • Go to that folder on terminal, and run ./configure
  • Then, go to /Applications/MAMP/bin/php/php5.6.10/include/php/bin
  • Run, for instance: sudo /Applications/MAMP/bin/php/php5.6.10/bin/pecl install memcache
  • Afterwards, edit your php.ini file (/Applications/MAMP/bin/php/php5.6.10/conf/php.ini), and add the line extension=memcache.so
  • Restart apache (on MAMP)
  • Profit!