首页 > 系统 > Ubuntu > 正文

ubuntu下安装redis

2024-06-28 13:25:28
字体:
来源:转载
供稿:网友
Ubuntu下安装redis

(1)进去 /usr/local目录下 cd /usr/local 若没有local这个文件夹则创建一个 sudo mkdir /usr/local sudo chmod 777 /usr/local (2)下载rediswget http://download.redis.io/releases/redis-2.8.12.tar.gz 解压 tar zxvf redis-2.8.12.tar.gz 重命名为:redis2.8 mv redis-2.8.12 redis2.8(3)编译, cd /usr/local/redis2.8 make (4)查看编译是否成功 cd /usr/local/redis2.8/src make test 若出现以下的提示错误,是因为没有装tcl,要装下tcl You need tcl 8.5 or newer in order to run the Redis test make: *** [test] Error 1 下载tcl放在/usr/local目录下进行安装 cd /usr/local wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz 解压 tar zxvf tcl8.6.1-src.tar.gz 解压好后,编译 cd tcl8.6.1/unix ./configure make make install

安装报错 error: jemalloc/jemalloc.h: No such file or directory解决方法:

make MALLOC=libc

安装好tcl后重新查看编译是否成功

cd /usr/local/redis2.8

cd src

make test

若查看结果如下,表示编译成功

/o/ All tests passed without errors!

Cleanup: may take some time... OK

(5)安装

cd/usr/local/redis2.8/src

make install

(6)redis命令默认目录:/usr/local/bin/

下载配置文件和启动脚本

wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-serverwget https://github.com/ijonas/dotfiles/raw/master/etc/redis.confsudo mv redis-server /etc/init.d/redis-serversudo chmod +x /etc/init.d/redis-serversudo mv redis.conf /etc/redis.conf

建立一个用户redis,并新建data和日志文件夹

sudo useradd redissudo mkdir -p /var/lib/redissudo mkdir -p /var/log/redissudo chown redis.redis /var/lib/redissudo chown redis.redis /var/log/redis

设置开机自动启动

sudo update-rc.d redis-server defaults

启动redis

sudo /etc/init.d/redis-server start


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表