MAMP下安装memcache

来源:互联网 发布:使命召唤4mac迅雷下载 编辑:程序博客网 时间:2024/06/10 08:13

原文地址

按照网上的教程,并不能顺利地安装下来,整合了几篇文章,并附上图片

参考:https://www.douban.com/note/337110939/

http://www.cnblogs.com/shengshuai/p/3696466.html

1: Memcached 推荐用  homebrew 安装。http://brew.sh/

2: 安装memcache ,

[html] view plain copy
  1. brew install memcached   



3: 我PHP用的是 5.6.6,编译 memcache 模块需要用到 php 源码,mamp 不自带,到 php 官网(http://www.php.net/downloads.php)下一个 php-5.6.25.tar.gz版本源码包,解压放到目录:    /Applications/MAMP/bin/php/php5.6.6/include/php

4:然后编译:

 /Applications/MAMP/bin/php/php5.6.6/include/php/configure

如果出现错误: configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

通过brew安装:

[html] view plain copy
  1. </pre><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;">brew search iconv</span><p></p><p class="p1"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"></span></span></p><pre name="code" class="html">brew install libiconv  

安装之后,我们再使用./configure安装php,还是报相同错误,也就是:configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

这是因为我们虽然安装了libiconv,但是没有指定目录,我们这样:

./configure --with-iconv=/usr/local/Cellar/libiconv/1.14/

这样就可以编译成功了~~


5: 

[html] view plain copy
  1. /Applications/MAMP/bin/php/[php version folder]/bin/pecl i memcache  
这里可能出现错误: 

configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located

ERROR: `/private/tmp/pear/temp/memcache/configure --enable-memcache-session=yes' failed

这个问题引起是因为zlib在安装时没有正确被引入,解决的办法是使用brew进行zlib的安装

[html] view plain copy
  1. brew install zlib    
安装后执行pecl i memcache 时还会出现同样的问题,需要将zlib的头文件及库文件添加至系统默认的路径

[html] view plain copy
  1. ln -s /usr/local/Cellar/zlib/1.2.8/include/* /usr/local/include    
  2. ln -s /usr/local/Cellar/zlib/1.2.8/lib/* /usr/local/lib    
然后再执行
[html] view plain copy
  1. /Applications/MAMP/bin/php/[php version folder]/bin/pecl i memcache  


6: 至此安装完成,点 mamp 菜单,file->edit template -> php -> php 5.6.6 php.ini ,增加:

[memcache]

 extension=memcache.so

7:打开phpinfo(),



启动memcache:

/usr/local/bin/memcached -p 11211 -m 64 -u root -d