wget https://download.redis.io/releases/redis-7.0.2.tar.gz
tar zxf redis-7.0.2.tar.gz
mv redis-7.0.2 /usr/local/redis
cd /usr/local/redis
archlinux
pacman -S gcc automake autoconf libtool make which pkg-config
centos
yum install -y gcc automake autoconf libtool make which pkg-config
ubuntu
apt install -y gcc automake autoconf libtool make which pkg-config
再进行make
- 如果执行make命令报错:致命错误:jemalloc/jemalloc.h: 没有那个文件或目录,则需要在make指定分配器为libc。执行下面命令即可正常编译
make MALLOC=libc
make install PREFIX=/usr/local/redis
将配置文件的daemonize no改为daemonize yes
设置密码 #requirepass foobared去掉注释,foobared改为自己的密码
requirepass uePisNRS
ln /usr/local/redis/bin/redis-server /usr/local/bin/
redis-server redis.conf
vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis Server
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf
TimeoutSec=0
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start redis
systemctl status redis
# 开机启动服务
systemctl enable redis
评论区