标签:
方法一:使用命令安装(前提是已经安装了EPEL)。
安装redis:
yum -y install redis
启动/停止/重启 Redis
启动服务:
1
systemctl start redis.service
停止服务:
systemctl stop redis.service
重启服务:
systemctl restart redis.service
检查状态:
[root@idoseek ~]# systemctl status redis.service
redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled)
Active: active (running) since 二 2014-10-21 21:37:22 EDT; 5h 26min ago
Main PID: 30413 (redis-server)
CGroup: /system.slice/redis.service
└─30413 /usr/bin/redis-server 127.0.0.1:6379
10月 21 21:37:22 idoseek.com systemd[1]: Started Redis persistent key-value database.
随系统启动服务:
[root@idoseek ~]# systemctl enable redis.service
ln -s ‘/usr/lib/systemd/system/redis.service‘ ‘/etc/systemd/system/multi-user.target.wants/redis.service‘
关闭随机启动:
[root@idoseek ~]# systemctl disable redis.service
rm ‘/etc/systemd/system/multi-user.target.wants/redis.service‘
方法二:编译安装
下载安装编译:
# wget http://download.redis.io/releases/redis-2.8.17.tar.gz
# tar xzf redis-2.8.17.tar.gz
# cd redis-2.8.17
# make
# make install
设置配置文件路径:
# mkdir -p /etc/redis && cp redis.conf /etc/redis
修改配置文件:
# vim /etc/redis/redis.conf
修改为: daemonize yes
启动Redis:
# /usr/local/bin/redis-server /etc/redis/redis.conf
#关闭服务
redis-cli shutdown
或者在cli中执行shutdown
redis 127.0.0.1:6379> shutdown
清除缓存
redis-cli flushall
更多文档请参考软件包内的“README”文件。
查看状态 :
# ss -nlp|grep redis
或者
# ps -ef | grep redis
下面介绍为PHP添加redis插件。
从官网下载最新的拓展,地址:http://pecl.php.net/package/redis或者https://github.com/phpredis/phpredis
#wget http://pecl.php.net/get/redis-2.2.5.tgz
#phpize
#./configure --prefix=/opt/redis --enable-redis --with-php-config=/opt/php/bin/php-config
#make && make install
把拓展添加至php.ini,重启php-fpm:
service php-fpm restart
http://www.111cn.net/sys/CentOS/85292.htm
标签:
原文地址:http://www.cnblogs.com/Leo_wl/p/5484163.html