HomeInstallation and Upgrade ManualHelpSpot 5 InstallationOptional Redis Server Configuration

1.11. Optional Redis Server Configuration

This guide provides step-by-step instructions for manually setting up and configuring Redis for HelpSpot usage. Redis is not generally required for running HelpSpot but utilizing Redis can solve performance issues on some large HelpSpot installations. This is based on an Ubuntu setup of HelpSpot. Other distributions will need slightly different steps.

Overview

This guide will walk you through:

  1. Installing Redis server
  2. Installing the PHP Redis extension
  3. Configuring Redis with AOF persistence and security settings
  4. Configuring HelpSpot to use Redis for caching, queues, and sessions
  5. Verifying the setup is working correctly

Installation

Step 1: Install Redis Server

Install Redis server from the default Ubuntu repositories:

# Update package lists
sudo apt-get update

# Install Redis server
sudo apt-get install -y redis-server

After installation, Redis will be automatically started. You can verify it's running:

# Check Redis service status
systemctl status redis

# Test Redis is responding
redis-cli ping
# Should return: PONG

Step 2: Install PHP Redis Extension

HelpSpot requires the PHP Redis extension to communicate with Redis. Install it for your PHP version:

# For PHP 8.3 (adjust version number if using a different PHP version)
sudo apt-get install -y php8.3-redis

# Restart PHP-FPM to load the extension
sudo systemctl restart php8.3-fpm

Verify the extension is installed:

php -m | grep redis
# Should output: redis

If you're using a different PHP version, replace php8.3 with your version (e.g., php8.2, php8.1, etc.).

Configuration Steps

Now that Redis is installed, we'll configure it for HelpSpot usage.

1. Stop Redis Service

Stop Redis before making configuration changes:

sudo systemctl stop redis

2. Configure Redis Settings

Edit the Redis configuration file at /etc/redis/redis.conf to enable AOF persistence and ensure proper security settings.

Key Configuration Changes:

Edit /etc/redis/redis.conf and verify/set these values:

# Security - bind to localhost only
bind 127.0.0.1

# Persistence - enable AOF for better durability
appendonly yes
appendfsync everysec

# Disable RDB snapshots (comment out all save directives)
# save 900 1
# save 300 10
# save 60 10000

3. Start Redis Service

Start Redis and enable it to start on boot:

# Start Redis
sudo systemctl start redis

# Enable Redis to start on boot
sudo systemctl enable redis

# Verify it's running
sudo systemctl status redis

Configure HelpSpot to Use Redis

After Redis is installed and running, configure HelpSpot to use Redis for caching and queues.

Important Notes Before Configuration

⚠️ Session Driver Warning: Changing SESSION_DRIVER to Redis will immediately log out all users. Consider:

⚠️ Queue Connection Warning: Changing to the redis queue driver from the database based queue driver will orphan any queue jobs that are currently in the queue. We'd recommend doing this during a maintenance window.

💡 Incremental Enablement: You can enable these drivers independently:

  1. Start with: CACHE_DRIVER=redis (safest, immediate performance boost)
  2. Then add: QUEUE_CONNECTION=redis (improves background job processing)
  3. Optionally add: SESSION_DRIVER=redis (be careful with implementing, this will log out all current users)

Configuration Steps

Edit the HelpSpot .env file (typically located at /var/www/helpspot/.env):

sudo nano /var/www/helpspot/.env

Add or update these lines (choose which drivers to enable based on your needs):

# Recommended: Enable cache driver (safe, no user impact)
CACHE_DRIVER=redis

# Recommended: Enable queue driver (see notes above)
QUEUE_CONNECTION=redis

# Optional: Enable session driver (will log out all users!)
SESSION_DRIVER=redis

# Redis connection settings (optional - these are the defaults)
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=null
REDIS_DB=0

Environment Variable Descriptions:

Cache & Queue (Safe to enable anytime):

Sessions (Logs out all users when enabled):

Optional Connection Settings (Laravel defaults shown):

Note: If using the default Redis configuration from this guide (localhost, port 6379, no password), you don't need to explicitly set the REDIS_* variables - Laravel will use these defaults automatically.

After making changes to the .env file, clear the application cache:

cd /var/www/helpspot
sudo -u www-data php artisan config:clear
sudo -u www-data php artisan cache:clear

If you're using Supervisor to manage HelpSpot queue workers, restart them to pick up the changes:

sudo supervisorctl restart all

Important Notes

  1. Data Directory: Redis will use the default /var/lib/redis directory for data storage

  2. Persistence Strategy: This configuration uses AOF (Append-Only File) persistence with everysec fsync, which provides good durability (loses at most 1 second of data) while maintaining performance

  3. Security: Redis is bound to localhost only (127.0.0.1), making it inaccessible from external networks. This is the recommended configuration for HelpSpot.

  4. No RDB Snapshots: RDB snapshot persistence is disabled to rely solely on AOF for persistence, which provides better durability guarantees

  5. HelpSpot Integration: HelpSpot can use Redis for:

    • Caching - Speeds up frequent database queries and application data
    • Queue Processing - Background jobs for email sending, notifications, etc.
    • Sessions (optional) - User session storage for better scalability
  6. Redis Connection: HelpSpot connects to Redis using the default host (127.0.0.1) and port (6379). No additional Redis configuration is needed beyond what's in this guide.

Troubleshooting

Redis fails to start

Check the logs:

sudo journalctl -u redis -n 50 --no-pager
sudo tail -100 /var/log/redis/redis-server.log

Common issues:

Permission denied errors

Ensure the data directory has correct ownership:

sudo chown -R redis:redis /var/lib/redis
sudo chmod 750 /var/lib/redis

Configuration not taking effect

After making configuration changes, always restart Redis:

sudo systemctl restart redis

You can verify current running configuration with:

redis-cli CONFIG GET '*' | less

HelpSpot not connecting to Redis

If HelpSpot isn't using Redis after configuration:

  1. Verify Redis is running and accessible:

    redis-cli ping
    # Should return: PONG
    
  2. Check that the .env file has the correct settings:

    grep -E "CACHE_DRIVER|QUEUE_CONNECTION|SESSION_DRIVER" /var/www/helpspot/.env
    
  3. Check HelpSpot logs for Redis connection errors:

    sudo tail -100 /var/www/helpspot/storage/logs/helpspot.log
    
  4. Verify the PHP Redis extension is installed:

    php -m | grep redis
    # Should show: redis
    

If the Redis extension is not installed:

sudo apt-get install -y php-redis
sudo systemctl restart php8.3-fpm

This page was: Helpful | Not Helpful