Redis安裝配置

Redis安裝

Ubuntu中安裝配置Redis

下載源碼包解壓編譯安裝

$ 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

//啟動(dòng)redis服務(wù)
$ cd src
$ ./redis-server

//通過(guò)啟動(dòng)參數(shù)告訴redis使用指定配置文件使用下面命令啟動(dòng)
$ cd src
$ ./redis-server redis.conf

//測(cè)試客戶端程序redis-cli和redis服務(wù)交互
$ cd src
$ ./redis-cli

使用Ubuntu包管理工具安裝

$ sudo apt-get update

# 安裝Redis服務(wù)器
$ sudo apt-get install redis-server

# 啟動(dòng) Redis
$ redis-server

# 查看 redis 是否啟動(dòng)?
$ redis-cli
redis 127.0.0.1:6379>
redis 127.0.0.1:6379> ping
PONG

127.0.0.1 是本機(jī) IP ,6379 是 Redis 服務(wù)端口?,F(xiàn)在我們輸入 ping 命令,若出現(xiàn) PONG 說(shuō)明我們已經(jīng)成功安裝了redis。

Windows安裝配置Redis

Windows下載Redis地址

https://github.com/MicrosoftArchive/redis/releases

核心程序

  • redis.windows.conf Redis配置文件
  • redis-server.exe Redis服務(wù)器
  • redis-cli.exe Redis命令行
  • redis-benchmark.exe Redis性能測(cè)試工具
Windows Redis核心程序

Windows下啟動(dòng)Redis服務(wù)器

C:\redis
$ redis-server redis.windows.conf
[19236] 09 Mar 11:09:40.991 # Creating Server TCP listening socket *:6379: bind: No error

Windows下Redis客戶端連接服務(wù)器

$ redis-cli -h 192.168.1.121 -p 6379 --raw

Redis可視化管理工具

Redis Desktop Manager
TreeNMS

下載解壓后,啟動(dòng)treeNMS > bin > startup.bat,然后瀏覽器訪問(wèn) 127.0.0.1:8086/treenms ,默認(rèn)賬戶 treesoft,默認(rèn)密碼 treesoft

Redis啟動(dòng)

# 查看Redis服務(wù)
$ systemctl status redis.service
$ systemctl start redis.service
$ systemctl stop redis.service
$ systemctl restart redis.service

# 關(guān)閉Redis進(jìn)程
$ pkill -9 redis-server

# 查看Redis進(jìn)程
$ ps -aux | grep redis
redis      742  0.1  0.1  58552  3712 ?        Ssl  01:41   0:00 /usr/bin/redis-server 0.0.0.0:6379
jc        1878  0.0  0.0  21536  1148 pts/0    S+   01:48   0:00 grep --color=auto redis

# 查看6379端口
$ sudo netstat -tunple|grep 6379
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      123        20211      742/redis-server 0. 
tcp6       0      0 ::1:6379                :::*                    LISTEN      123        20212      742/redis-server 0. 

為PHP配置Redis擴(kuò)展

$ wget https://github.com/nicolasff/phpredis/zipball/master -o php-redis.zip
$ unzip php-redis.zip
$ cd php-redis
$ phpize
$ sudo apt-get install php-dev
$ makefile:./configure
$ make
$ make install

Redis配置文件

設(shè)置Redis服務(wù)器后臺(tái)運(yùn)行

# 修改redis的配置文件
$ sudo vim /etc/redis/redis.conf
# 將守護(hù)進(jìn)程配置項(xiàng)打開,配置redis-server后臺(tái)運(yùn)行。
daemonize yes

設(shè)置Redis服務(wù)外部可訪問(wèn)

$ sudo vim /etc/redis/redis.conf
# 綁定地址
bind 0.0.0.0 ::1
# 關(guān)閉保護(hù)模式
protected-mode no
# 默認(rèn)有16個(gè)數(shù)據(jù)庫(kù),數(shù)據(jù)庫(kù)下標(biāo)從0開始。默認(rèn)為0下標(biāo)的數(shù)據(jù)庫(kù)。
databases 16
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容