1. 安裝位置:
這裏選擇/opt
cd /opt
2. 下載安裝Redis:
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar xzf redis-5.0.7.tar.gz
cd redis-5.0.7
make
如果報make或者cc命令無法找到,則執行以下命令:
yum -y install make
yum install gcc
安裝好gcc和make後,需要將原來解壓出的文件刪除,重新解壓一遍,命令如下:
rm -rf redis-5.0.7
tar xzf redis-5.0.7.tar.gz
cd redis-5.0.7
make
make完成會出現:Hint: It’s a good idea to run ‘make test’ 😉
此時執行
make test
進行測試,如果出現 “You need tcl 8.5 or newer in order to run the Redis test” 提示
cd /opt
wget http://downloads.sourceforge.net/tcl/tcl8.6.10-src.tar.gz
sudo tar xzvf tcl8.6.10-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
sudo ./configure
sudo make
sudo make install
服務器下載沒有速度,可以考慮手動下載然後傳到服務器:tcl8610-src.zip
unzip tcl8610-src.zip
mv tcl8.6.10/ /usr/local/
cd /usr/local/tcl8.6.1/unix/
sudo ./configure
sudo make
sudo make install
此時再進行make test即可:
cd /opt/redis-5.0.7
make test
3. 配置Redis
cd /opt/redis-5.0.7
vi redis.conf
移動光標找到對應字段,然後按i鍵進行編輯,編輯完後按Esc鍵,然後輸入:wq進行保存。
# 首先,將IP綁定localhost給註銷掉,這樣就可以接受來自任何IP的請求:
# bind 127.0.0.1
# 然後將保護模式關閉,保護模式會在沒有綁定特定IP並且沒有設置密碼的情況下,只接受本地的請求。
protected-mode no
# 這裏改爲yes,使服務成爲後臺應用,這樣關閉現在的終端也能運行:
daemonize yes
# 如果有需要,可以設置Redis連接密碼,將下面字段foobared改爲自己的密碼,並取消註釋。
# requirepass foobared
4. 運行Redis服務
/opt/redis-5.0.7/src/redis-server /opt/redis-5.0.7/redis.conf
查看Redis進程:
ps -ef | grep redis
5. 查看Redis
此處推薦一個免費好用的客戶端:Another Redis Desktop Manager