- 安装memcached服务
- brew install memcached
- 配置开机启动(用brew安装之后下面会提示怎么启动)
- ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents
- launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist
- 启动memcached
- memcached –d –m 2048 –p 11211
- 说明:以守护进程运行memcache并设置2g内存,端口是11211
- 测试memcache是否启动
- telnet 127.0.0.1 11211
- 安装memcache扩展
- wget http://pecl.php.net/get/memcache-3.0.8.tgz
- tar -xf ./memcache-1.4.tgz
- cd memcache-1.4
- phpize
- ./configure
- make
- sudo make install
- 安装完毕看到
- Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20090626/
- 修改php.ini
- 添加extension=memcache.so
- 重启apache或者nginx即可
备注:memcache服务端和客户端要一致,以免发生其他意外