How to Install and Configure Redis on Your Linux VPS or Dedicated Server Updated on April 15, 2026 by Carrie Smaha 5 Minutes, 33 Seconds to Read Redis is an open-source, in-memory key-value data store used as a high-performance object cache, session handler, message broker, and full-featured database. On InMotion Hosting VPS and dedicated servers, Redis dramatically speeds up dynamic websites (especially WordPress, Magento, Laravel, and Drupal) by caching database queries, API responses, and rendered pages in RAM. It reduces load on MySQL/MariaDB and can improve response times by 60-80% in cache-heavy applications. This updated, thorough guide covers installation on modern distributions supported by InMotion (AlmaLinux 8/9, Ubuntu 22.04/24.04, and similar), PHP integration, secure configuration, testing, and optimization best practices as of 2026. The instructions apply to servers with root or sudo access. Table of Contents What Is Redis and Why Use It on a VPS? Prerequisites Step 1: Update Your System Step 2: Install Redis Server On AlmaLinux 8 or 9 (Recommended for InMotion cPanel Servers) On Ubuntu 22.04 or 24.04 Step 3: Start and Enable Redis Service Step 4: Basic Configuration and Security Hardening Step 5: Install the PHP Redis Extension Step 6: Test Your Redis Installation Step 7: Integrate Redis with Your Application WordPress Object Caching Laravel or Other Frameworks PHP Session Handler (Optional) Additional Optimizations and Best Practices Troubleshooting Common Issues What Is Redis and Why Use It on a VPS? Redis stores data in memory for sub-millisecond access while offering optional persistence (RDB snapshots or AOF append-only files). Common uses on a VPS include: Object caching for PHP applications Full-page caching Session storage (faster than file-based sessions) Rate limiting and queues Real-time analytics or leaderboards Redis excels in high-concurrency environments but consumes RAM, so monitor usage carefully on resource-limited VPS plans. Prerequisites A Linux VPS or dedicated server with at least 2 GB RAM (4 GB+ recommended for production caching). Root or sudo privileges. SSH access. Updated system packages. PHP installed (for web application integration). Firewall configured (firewalld on AlmaLinux or UFW on Ubuntu). Note: This guide is for VPS/dedicated servers. Shared hosting does not allow custom Redis installation. Step 1: Update Your System Always start with a full update: On AlmaLinux / RHEL-based (cPanel servers): sudo dnf update -y On Ubuntu / Debian-based: sudo apt update && sudo apt upgrade -y Step 2: Install Redis Server On AlmaLinux 8 or 9 (Recommended for InMotion cPanel Servers) Install the EPEL repository (if not present): sudo dnf install epel-release -y Install Redis from the repositories: sudo dnf install redis -y For newer Redis versions (e.g., Redis 7+ or 8.x via Remi repository): sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm -y sudo dnf module reset redis -y sudo dnf module enable redis:remi-8.0 -y # or remi-7.4 / remi-7.2 as needed sudo dnf install redis -y On Ubuntu 22.04 or 24.04 Redis is available in the official repositories: sudo apt install redis-server -y For the absolute latest stable version, add the official Redis repository: sudo apt install lsb-release curl gpg -y curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list sudo apt update sudo apt install redis -y Step 3: Start and Enable Redis Service AlmaLinux: sudo systemctl start redis sudo systemctl enable redis sudo systemctl status redis Ubuntu: sudo systemctl start redis-server sudo systemctl enable redis-server sudo systemctl status redis-server Step 4: Basic Configuration and Security Hardening Edit the main configuration file: AlmaLinux: /etc/redis/redis.confUbuntu: /etc/redis/redis.conf Key recommended changes (uncomment or modify): # Bind only to localhost for security (default on most installs) bind 127.0.0.1 ::1 # Or bind to a specific private IP if needed # bind 127.0.0.1 your-private-ip # Require a strong password (highly recommended for production) requirepass YourVeryStrongPasswordHere123! # Protect against common attacks protected-mode yes # Limit memory usage (adjust to your VPS RAM; leave headroom for OS) maxmemory 512mb ; Example for a 2-4 GB VPS maxmemory-policy allkeys-lru ; Evict least recently used keys when full # Persistence (enable for durability) appendonly yes appendfsync everysec # Disable dangerous commands if not needed rename-command FLUSHALL "" rename-command FLUSHDB "" rename-command KEYS "" Generate a strong password (run this command): openssl rand -base64 32 After editing, restart Redis: sudo systemctl restart redis # AlmaLinux # or sudo systemctl restart redis-server # Ubuntu Firewall Configuration firewalld (AlmaLinux): Redis should remain bound to localhost, so no port opening is usually needed. If remote access is required (not recommended), open port 6379 only from trusted IPs. UFW (Ubuntu): sudo ufw allow from 127.0.0.1 to any port 6379 sudo ufw reload Important Security Note: Never expose Redis (port 6379) to the public internet without strong authentication, TLS, or a VPN/SSH tunnel. Most attacks on Redis target unprotected instances. Step 5: Install the PHP Redis Extension To use Redis as an object cache or session handler with PHP: AlmaLinux (with EasyApache / MultiPHP): sudo dnf install php-redis -y # or for specific PHP version via Remi sudo dnf install php81-php-redis -y # adjust version Ubuntu: sudo apt install php-redis -y sudo phpenmod redis For multiple PHP versions, specify the version: sudo apt install php8.3-redis -y sudo phpenmod -v 8.3 redis Restart your web server (Apache or NGINX) and PHP-FPM: sudo systemctl restart httpd # AlmaLinux/Apache sudo systemctl restart apache2 # Ubuntu/Apache sudo systemctl restart php8.3-fpm # Adjust version Step 6: Test Your Redis Installation Basic connectivity test: redis-cli ping Expected response: PONG Test with authentication (if requirepass is set): redis-cli -a YourVeryStrongPasswordHere123! ping Interactive test: redis-cli > SET testkey "Hello Redis" > GET testkey > KEYS * > QUIT Check service status and logs: sudo systemctl status redis sudo journalctl -u redis -f # or redis-server on Ubuntu Step 7: Integrate Redis with Your Application WordPress Object Caching Install a plugin such as Redis Object Cache (by Till Krüss) or LiteSpeed Cache. In wp-config.php: define('WP_REDIS_HOST', '127.0.0.1'); define('WP_REDIS_PORT', 6379); define('WP_REDIS_PASSWORD', 'YourVeryStrongPasswordHere123!'); define('WP_REDIS_TIMEOUT', 1); define('WP_REDIS_READ_TIMEOUT', 1); Laravel or Other Frameworks Configure in .env: REDIS_HOST=127.0.0.1 REDIS_PASSWORD=YourVeryStrongPasswordHere123! REDIS_PORT=6379 PHP Session Handler (Optional) In php.ini or pool config: session.save_handler = redis session.save_path = "tcp://127.0.0.1:6379?auth=YourVeryStrongPasswordHere123!" Additional Optimizations and Best Practices Monitor Memory Usage: Use redis-cli INFO memory or tools like htop. Persistence Tuning: Choose RDB for speed or AOF for durability. Maxmemory Policy: allkeys-lru or volatile-lru are common for caching. Separate Pools: For multiple sites, consider multiple Redis instances or databases (SELECT 0-15). Backup Data: Regularly back up /var/lib/redis/ or use Redis persistence files. Updates: Keep Redis updated for security patches. If you use InMotion Hosting’s UltraStack or Managed VPS, Redis works seamlessly with existing PHP-FPM and caching layers. Troubleshooting Common Issues Connection Refused: Check if Redis is running and bound correctly. NOAUTH Authentication required: Add the password to your client configuration. Out of Memory: Lower maxmemory or upgrade VPS RAM. PHP Redis extension not loading: Verify with php -m | grep redis and restart services. For advanced configurations (Redis Cluster, Sentinel, or TLS), consult the official Redis documentation or contact InMotion Hosting support with your server details. You have now installed, secured, and integrated a production-ready Redis instance on your VPS or dedicated server. This setup provides a powerful caching layer that significantly boosts website performance while maintaining security and stability. Test thoroughly under load before going live. Leave the Technical Heavy Lifting to Us Whether you need server tweaks, security updates, or scalability support, our sysadmin team has you covered. Get support that matches your business needs and keeps your site running strong. Explore InMotion Solutions Plans Share this Article Carrie Smaha Senior Manager Marketing Operations Carrie Smaha is a Senior Marketing Operations leader with over 20 years of experience in digital strategy, web development, and IT project management. She specializes in go-to-market programs and SaaS solutions for WordPress and VPS Hosting, working closely with technical teams and customers to deliver high-performance, scalable platforms. At InMotion Hosting, she drives product marketing initiatives that blend strategic insight with technical depth. More Articles by Carrie Related Articles Use rsync to transfer files Exporting your Database for Transfer How to Generate SSH Keys and Set Up SSH Key Authentication How to Install and Configure Redis on Your Linux VPS or Dedicated Server How to Fix the PHP-FPM “server reached max_children” Error How to Connect to Your Server with SSH How InMotion Hosting Solved MySQL Memory Leaks at Scale with TCMalloc How Can I View My CPU Usage in cPanel? How to Send Files to the Trash Can in Linux with Gio Trash Engrampa Archive Manager for Linux