Install Redis from Source

To install Redis from the source, run

cd /usr/local/src
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
make install

Copy config file

mkdir /etc/redis/
cp /usr/local/src/redis-stable/redis.conf  /etc/redis/

Create redis user

groupadd -r redis
useradd -r -g redis -s /sbin/nologin -d /var/lib/redis -c "redis Daemons" redis

Create directory

mkdir /var/lib/redis
chown redis:redis /var/lib/redis
chmod 770 /var/lib/redis

Set data directory

vi /etc/redis/redis.conf

Find

dir ./

Replace with

dir /var/lib/redis

Create service file

vi /usr/lib/systemd/system/redis.service

Add the following content to the file

[Unit]
Description=Redis persistent key-value database
After=syslog.target

[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
RestartSec=5s
Restart=on-success
User=redis
Group=redis

[Install]
WantedBy=multi-user.target

Enable and start Redis

systemctl enable redis
systemctl start redis

To find Redis version, run

redis-server --version

To monitor Redis, you can use redis-cli

Back to redis

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *