• 1. Update the OS Packages

sudo apt-get update
sudo apt-get upgrade

  • Install Build Dependencies

sudo apt-get install build-essential tcl wget curl

Download and Extract Redis Source

cd /opt/
wget http://download.redis.io/redis-stable.tar.gz
tar -xvzf redis-stable.tar.gz
cd redis-stable

Compile and Install Redis

make
sudo make install

Optional: Test Build
make test

  • Install Redis as a Service

cd utils/
sudo ./install_server.sh

  • Accept the default values when prompted.
  • This script creates startup scripts and sets up Redis under a specific port (usually 6379).

Enable and Start Redis Service

sudo systemctl enable redis_6379
sudo systemctl start redis_6379

  • Configure Redis

Create Directories and Redis User
sudo mkdir /etc/redis
sudo mkdir /var/www/redis
sudo adduser –system –group –no-create-home redis
sudo chown redis:redis /var/www/redis
sudo chmod 770 /var/www/redis

Copy and Edit the Config

sudo cp /opt/redis-stable/redis.conf /etc/redis/
sudo nano /etc/redis/redis.conf

Recommended Config Changes
port 6379
supervised systemd
logfile /var/log/redis.log
dir /var/www/redis/
bind 127.0.0.1 # or your actual IP address, depending on your security needs
Security Tip: If Redis is bound to a public interface, ensure you secure it with a password and firewall rules.

  • Create a Systemd Unit File

sudo nano /etc/systemd/system/redis.service

Paste the following content:

[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target

Reload Systemd, Start and Check Status

sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl start redis
sudo systemctl enable redis
sudo systemctl status redis

🔒 Security Notes

  • Version 4.0.10 is outdated (as of now). The latest Redis version is 7.x (or later). For security, use a newer Redis version unless there’s a specific compatibility reason.
  • Restrict network access with a firewall (ufw or iptables) or bind Redis only to localhost.
  • Use requirepass in redis.conf for basic authentication if Redis is exposed to any network.
  • Avoid direct exposure to the public internet unless absolutely necessary.

🔄 Upgrade Suggestion

Instead of using Redis 4.0.10, consider updating this guide to install the latest stable version from the official Redis GitHub releases or use Docker to simplify and isolate the setup process.

By admin