Linux下安装redis
安装软件:
wget http://download.redis.io/releases/redis-3.0.6.tar.gz .
wget --no-check-certificate https://pypi.python.org/packages/source/r/redis/redis-2.8.0.tar.gz .
wget https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz .
安装redis
把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的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()
执行成功
pip安装
# tar -xzvf pip-1.5.4.tar.gz
# cd pip-1.5.4
# python setup.py install
安装Python的redis包需要机器能联网:
pip install -i http://mirrors.aliyun.com/pypi/simple redis (阿里的包)
https://pypi.python.org/pypi/redis/
easy_install pip && pip install redis