Using Redis

Redis Installation Guide for Linux Server

Prerequisites

Before installing Redis, ensure your Linux server is up to date:

sudo apt update
sudo apt upgrade -y

Ubuntu/Debian

sudo apt install redis-server -y

CentOS/RHEL/Fedora

sudo yum install redis -y
# or for newer versions
sudo dnf install redis -y

Configuration

Basic Configuration

The main Redis configuration file is typically located at /etc/redis/redis.conf.

# Open configuration file
sudo nano /etc/redis/redis.conf

Key configuration settings to consider:

Configure Redis as a Service

If you installed from source, create a systemd service file:

Add the following content:

Create Redis user and directories:

Managing Redis Service

Start Redis

Enable Redis to start on boot

Check Redis status

Stop Redis

Restart Redis

Verify Installation

Test if Redis is working properly:

Security Recommendations

  1. Set a strong password in the configuration file using requirepass

  2. Bind to localhost if Redis is only used locally:

  3. Configure firewall to restrict access:

  4. Disable dangerous commands in production:

  5. Run Redis as non-root user (handled automatically when installed via package manager)

Laravel Integration

If you're using Redis with Laravel, install the required PHP extension:

Update your Laravel .env file:

Troubleshooting

Check Redis logs

Test Redis connection

Check Redis memory usage

Monitor Redis in real-time

Additional Resources

  • Official Redis Documentation: https://redis.io/documentation

  • Redis Commands Reference: https://redis.io/commands

  • Redis Security Guide: https://redis.io/topics/security

Last updated

Was this helpful?