把redis安裝到 /opt/redis-2.8目錄中
- wget http://download.redis.io/releases/redis-2.8.1.tar.gz
- tar -zxfx redis-2.8.1.tar.gz
- cd redis-2.8.1
- make && make PREFIX=/opt/redis-2.8 install
- cp redis.conf /opt/redis-2.8/
只是把redis當做隊列用,不需要存儲,所以編輯 /opt/redis-2.8/redis.conf
- 設置 daemonize yes
- 把3條
save ..
都注釋掉,這樣就關閉了硬盤存儲
啟動redis 非常簡單: /opt/redis-2.8/bin/redis-server /opt/redis-2.8/redis.conf
$REIDS_INSTALL_DIR/utils/redis_init_script
這個腳本稍做修改就可以放到/etc/init.d 作為redis啟動腳本用
安裝python
CentOS 自帶的python2.4,太舊了,升級到2.7
- wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
- tar -zvxf Python-2.7.6.tgz
- cd Python-2.7.6
- ./configure
- make && make install
- 替換系統默認的python:
sudo ln -s /usr/local/bin/python2.7 /usr/bin/python
安裝python的redis模塊
- wget --no-check-certificate https://pypi.python.org/packages/source/r/redis/redis-2.8.0.tar.gz
- tar -zvxf redis-2.8.0.tar.gz
- mv redis-2.8.0 python-redis-2.8.0
- cd python-redis-2.8.0
- python setup.py install
部署成功,寫段代碼驗證一下
import redis
client = redis.StrictRedis(host='localhost', port=6379)
print client.ping()
True
執行成功