CentOS7/RHEL7安裝Redis步驟詳解

來源:互聯網
上載者:User
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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.