操作步骤
1.检测memcached源
yum search memcached
2.install 安装
yum -y install -enablerepo=rpmforge memcached php-pecl-memcache
3.验证
memcached -h
4.设置开机启动
chkconfig memcached on
5.启动服务
service memcached start
php -m|grep memcache#测试服务端是否安装成功
lsof -i tcp:11211 #检测端口号是否正常
6.配置php.ini
extension=/usr/lib64/php/modules/memcache.so
测试
<?php
$mem = new Memcache();
$mem->connect(‘127.0.0.1’,11211);
$mem->set(‘key’,’test’,0,0);
$val = $mem->get(‘key’);
echo $val;