[置顶] centos yum安装memcached及php memcache扩展
2018-01-22 10:04
483 查看
注意事项:
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;
?>
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;
?>
相关文章推荐
- centos yum安装memcached及php memcache扩展
- centos yum安装memcached及php memcache扩展
- Centos 6.6(X64位)系统编译安装memcached 并安装PHP的memcache扩展
- php扩展memcache和memcached安装
- memcached服装已安装php扩展也装了,报错:Notice: Memcache::connect(): Server 127.0.0.1 (tcp 11211, udp 0) failed wi
- php扩展memcached、memcache、redis的安装配置方法
- php下memcache的应用(三)——linux下php扩展memcached的安装
- php-memcache扩展和php-memcached扩展安装
- Linux中搭建memcached,并为php安装memcache扩展
- PHP7 下安装 memcache 和 memcached 扩展
- 关于Windows7 下面安装memcached和php的memcache扩展
- 编译安装libevent,memcache,以及php的memcached扩展
- php安装memcache和memcached扩展
- memcached的安装以及php两个扩展软件安装(memcache、memcached)
- Windows64位32位上安装memcached和php的memcache扩展dll
- php扩展memcached和memcache的安装配置方法
- Linux安装Memcache与安装php memcached扩展
- centos 5.7 安装PHP扩展memcached memcache redis mongo
- ubuntu安装php扩展memcache与memcached
- CentOS安装memcached及配置php的memcache扩展