Memcache安装
注意事项:
1 安装时注意权限问题 sudo
2 需先启动memcache服务 php才能测试
Memcached是高性能的,分布式的内存对象缓存系统,用于在动态应用中减少数据库负载,提升访问速度。
开始安装memcache
查找相关软件包
#yum search memcache
有了,现在可以安装了
#yum -y install –enablerepo=rpmforge memcached php-pecl-memcache
#如果提示没安装成功 yum update一下 然后再执行命令 成功即把memcache服务端和php memcache扩展都安装好 会在/usr/lib64/php/modules/memcache.so
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* atomic: mirrors.neusoft.edu.cn
* base: mirrors.btte.net
* extras: mirrors.yun-idc.com
* updates: mirrors.btte.net
Setting up Install Process
Error: Nothing to do
验证一下安装结果
#memcached -h
#php -m|grep memcache
设置开机启动
#chkconfig memcached on
启动memcached
#service memcached start
到这里memcache服务端安装成功 测试安装是否成功
[root@localhost usr]# php -m|grep memcache
memcache
[root@localhost usr]# lsof -i tcp:11211
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
memcached 3399 memcached 26u IPv4 12677364 0t0 TCP *:memcache (LISTEN)
memcached 3399 memcached 27u IPv6 12677365 0t0 TCP *:memcache (LISTEN)
已经在侦听 说明成功 会生成memcache.so 32位在/usr/lib/中 64位在/usr/lib64/
接下来加载php memcache扩展
php.ini中开启 extension=/usr/lib64/php/modules/memcache.so
/etc/init.d/httpd restart #重启Apache
需先启动memcache 然后重启php-fpm 即可看到扩展 不需重启nginx
service php-fpm restart
代码测试:
mem.php
<?php
$mem = new Memcache;
$mem->connect("127.0.0.1", 11211);
$mem->set('key', 'This is a test2211!', 0, 60);
$val = $mem->get('key');
echo $val;
?>
相关文章
- pod(九):污点taint 与容忍度tolerations
- pod(八):pod的调度——将 Pod 指派给节点
- 全排列 next_permutation()
- cordon节点,drain驱逐节点,delete 节点
- 背包问题
- pod(七):静态pod
- pod(六):初始化容器Init Containers
- 钱币找零问题
- pod(五):pod hook(pod钩子)和优雅的关闭nginx pod
- pod(四):pod的重启策略和生命周期
- Ubiquitous Religions
- HDU1213 How many tables
- 1111. 有效括号的嵌套深度
- Istio(十三):Istio项目实际案例——Online Boutique
- 最小生成树-普利姆(Prim)算法
- 最短路径-弗洛伊德(Floyd)算法
- Istio(十二):Istio问题排查
- 最短路径-迪杰斯特拉(Dijkstra)算法
- Istio(十一):向istio服务网格中引入虚拟机
- 哈夫曼树