Ubuntu Linux下安装 Redis 并配置开机启动
1、下载安装:
- cd/tmp
- wgethttp://redis.googlecode.com/files/redis-2.2.13.tar.gz
- tar-zxf redis-2.2.13.tar.gz
- cdredis-2.2.13
- make
- sudomakeinstall
这时Redis 的可执行文件被放到了/usr/local/bin
2、下载配置文件和init启动脚本:
- wgethttps://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server
- wgethttps://github.com/ijonas/dotfiles/raw/master/etc/redis.conf
- sudomvredis-server /etc/init.d/redis-server
- sudochmod+x /etc/init.d/redis-server
- sudomvredis.conf /etc/redis.conf
3、初始化用户和日志路径
第一次启动Redis前,建议为Redis单独建立一个用户,并新建data和日志文件夹
- sudouseraddredis
- sudomkdir-p /var/lib/redis
- sudomkdir-p /var/log/redis
- sudochownredis.redis /var/log/redis
4、设置开机自动启动,关机自动关闭
sudo update-rc.d redis-server defaults
5、启动Redis:
sudo /etc/init.d/redis-server start
如果没有输出如何信息,请检查
/etc/init.d/redis-server文件,查看里面redis的路径是否正确,下载的内容如下,
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/redis-server DAEMON_ARGS=/etc/redis.conf NAME=redis-server DESC=redis-server PIDFILE=/var/run/redis.pid test -x $DAEMON || exit 0 test -x $DAEMONBOOTSTRAP || exit 0
6、启动client客户端连接:
redis-cli原文链接:https://www.f2er.com/ubuntu/355818.html