merlin

精益求精

孤鸿

导航

[centos 6.3]php客户端memcached扩展安装

环境:centos 6.4 +lamp(yum安装)

获取memcache扩展

wget http://pecl.php.net/get/memcache-2.2.5.tgz

解压:

gzip -d memcache-2.2.5.tgz 

tar xvf memcache-2.2.5.tar

cd memcache-2.2.5

运行phpize:

phpize

Configuring for: 

PHP Api Version:         20041225 

   Zend Module Api No:      20060613 

   Zend Extension Api No:   220060519

 

./configure --enable-memcache --with-php-config=/usr/bin/php-config --with-zlib-dir

make && make insatll

Installing shared extensions: 

生成的扩展目录(/usr/lib/php/modules)

修改php.ini 增加以下两行

extension_dir = "/usr/lib/php/modules"‍

extension=memcache.so

service httpd restart 

phpinfo(); 发现已经有了memcache扩展

 

$mc =new Memcache();//生成memcached对象
$mc->connect('192.168.1.233',11211);//连接memcached服务器
$mc->set('test','hello world ',0,10);
$val =$mc->get('test');
$mc->delete('test');//删除值
$mc->flush();//刷新memcached所有缓存
$mc->close();//关闭连接

 

输出 hello world

 

 

 

posted on 2013-07-15 17:59  天地一连线_孤鸿挂飘渺  阅读(272)  评论(0编辑  收藏  举报