Installation guides

Installing Redis on Debian

Step-by-Step Guide

  1. Update the Package Index
    Open a terminal and update the package index to ensure you have the latest information about available packages:
   sudo apt update
  1. Install Redis
    Install Redis using the apt package manager:
   sudo apt install redis-server
  1. Configure Redis
    Open the Redis configuration file for editing:
   sudo nano /etc/redis/redis.conf

Make the following changes for better security and performance:

  • Set a password: Uncomment the requirepass directive and set a strong password.
    conf requirepass your_password
  • Bind to specific IP: By default, Redis listens on all available IP addresses. To restrict access, change the bind directive to your server’s IP address.
    conf bind 127.0.0.1
    Save and close the file.
  1. Enable Redis to Start on Boot
    Enable the Redis service to start at boot time:
   sudo systemctl enable redis-server
  1. Start Redis
    Start the Redis service:
   sudo systemctl start redis-server
  1. Verify Redis Installation
    Check the Redis service status to ensure it is running:
   sudo systemctl status redis-server

If Redis is running, you should see an active (running) status.

  1. Test Redis Installation
    To test the Redis installation, use the Redis CLI to connect to the Redis server:
   redis-cli

If you set a password, authenticate with:

   AUTH your_password

Once connected, you can test Redis by setting and getting a key:

   SET mykey "Hello, Redis!"
   GET mykey

You should see the response “Hello, Redis!”.

  1. Secure Redis (Optional)
    For additional security, consider configuring a firewall to restrict access to the Redis server. For example, if using UFW, allow access only from trusted IP addresses:
   sudo ufw allow from trusted_ip to any port 6379
  1. Enable Persistence (Optional)
    Redis supports two forms of persistence: RDB snapshots and AOF (Append Only File). To enable RDB snapshots, ensure the following lines are present in the Redis configuration file:
   save 900 1
   save 300 10
   save 60 10000

To enable AOF, uncomment and set the appendonly directive to yes:

   appendonly yes
  1. Monitor Redis
    You can monitor Redis performance and statistics using the redis-cli with the INFO command:
    bash redis-cli INFO
Other Recent Posts