Mac PHP安装Memcache扩展

##1、如果需要使用本地Memcache服务器,则应在本地安装Memcache服务器,即memcached

1、查找有没有memcached

[javascript] view plain copy

$ brew search memcache  

[javascript] view plain copy

$ brew search memcache  

返回结果:

[javascript] view plain copy

libmemcached    memcache-top    memcached   memcacheq

[javascript] view plain copy

libmemcached    memcache-top    memcached   memcacheq  

第一个是客户端,第三个是服务器。

2、安装服务器

[javascript] view plain copy

$ brew install memcached  

[javascript] view plain copy

$ brew install memcached  

3、如果需要开机自启动,输入以下命令

[javascript] view plain copy

$ ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents  

[javascript] view plain copy

$ ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents  

4、安装客户端和服务器类似

##2、安装PHP的memcache扩展 1、下载:下载稳定版的memcache包

下载地址为:http://pecl.PHP.NET/package/memcache

2、解压

[javascript] view plain copy

$ tar -xzf memcache-2.2.7.tgz  

[javascript] view plain copy

$ tar -xzf memcache-2.2.7.tgz  

3、编译

[javascript] view plain copy

$ cd memcache-2.2.7  

$ phpize  

$ ./configure --enable-memcache --with-php-config=/usr/local/opt/php54/bin/php-config --with-zlib-dir  

$ make & make install   

[javascript] view plain copy

$ cd memcache-2.2.7  

$ phpize  

$ ./configure --enable-memcache --with-php-config=/usr/local/opt/php54/bin/php-config --with-zlib-dir  

$ make & make install   

如果在make install 时提示,没权限,则:

[javascript] view plain copy

$ sudo make install  

[javascript] view plain copy

$ sudo make install  

然后输入密码进行编译

4、编辑php.ini文件,将下面一行加入文件

[javascript] view plain copy

$ extension = memcache.so  

[javascript] view plain copy

$ extension = memcache.so  

php.ini文件的位置:

[javascript] view plain copy

/usr/local/etc/php/5.4  

[javascript] view plain copy

/usr/local/etc/php/5.4  

5、重启php-fpm 和nginx

[javascript] view plain copy

$ killall php-fpm  

$ /usr/local/opt/php54/sbin/php-fpm -D  

[javascript] view plain copy

$ killall php-fpm  

$ /usr/local/opt/php54/sbin/php-fpm -D  

[javascript] view plain copy

$ nginx -s reload  

[javascript] view plain copy

$ nginx -s reload  

转载于:https://my.oschina.net/phpweishunlong/blog/907759

你可能感兴趣的:(Mac PHP安装Memcache扩展)