在Ubuntu中安装Redis
使用如下版本信息
Ubuntu 18.04 LTS
Redis 4.0.10
为Redis创建单独的安装和配置目录
root@ubuntu:~# mkdir /redis
root@ubuntu:~# mkdir /redis/conf
切换到/redis目录下,并下载Redis
root@ubuntu:~# cd /redis
root@ubuntu:/redis# wget http://download.redis.io/releases/redis-4.0.10.tar.gz
解压下载的源码
root@ubuntu:/redis# tar zxzf redis-4.0.10.tar.gz
切换到解压后/deps目录下的,编译依赖项目
root@ubuntu:/redis# cd redis-4.0.10/deps
root@ubuntu:/redis/redis-4.0.10/deps# make hiredis lua jemalloc linenoise
切换到/redis/redis-4.0.10,编译
root@ubuntu:/redis/redis-4.0.10/deps# cd ..
root@ubuntu:/redis/redis-4.0.10# make CFLAGS="-march=x86-64"
安装Redis
root@ubuntu:/redis/redis-4.0.10# make PREFIX=/redis install
将默认的配置文章复制到/redis/conf目录下,作为自定义Redis配置文件
root@ubuntu:/redis/redis-4.0.10# cp redis.conf /redis/conf
切换到/redis/conf目录下,将配置文件中的 deamonize设置为yes,这样Redis便会以守护进程的形式运行
root@ubuntu:/redis/redis-4.0.10# cd ..
root@ubuntu:/redis# cd conf
root@ubuntu:/redis/conf# vim redis.conf
使用/redis/conf目录下的redis.conf启动Redis
root@ubuntu:~# cd /redis
root@ubuntu:/redis# bin/redis-server conf/redis.conf
启动后,使用redis-cli即可连接到Redis
root@ubuntu:/redis# bin/redis-cli
关闭Redis
127.0.0.1:6379> shutdown

浙公网安备 33010602011771号