CentOS7/RHEL7安裝Redis步驟詳解 CentOS7/RHEL7安裝Redis還是頭一次測試安裝了,因為centos7升級之後與centos6有比較大的區別了,下面我們就一起來看看CentOS7/RHEL7安裝Redis步驟詳解
方法一:使用命令安裝(前提是已經安裝了EPEL)。
安裝redis:
yum -y install redis
啟動/停止/重啟 Redis
加入開機啟動
systemctl enable redis
啟動redis服務進程
systemctl start 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