How to Install Redis on cPanel

Below is a complete, step-by-step guide on how to install Redis on a cPanel / WHM server running CentOS/AlmaLinux/Rocky Linux (the most common distros).

The method uses EasyApache 4 to compile the PHP Redis extension and enables Redis as a system service.

Prerequisites

  • Root or sudo SSH access to the server
  • cPanel/WHM ≥ v110 (EA4)
  • At least 1 GB free RAM (Redis is lightweight, but PHP needs it)
  • Backup your server before proceeding

1. Update the System

yum update -y   # or dnf update -y on AlmaLinux 8+/Rocky 8+

2. Install Redis Server (via EPEL + Remi)

# Enable EPEL
yum install -y epel-release

# Enable Remi repo (contains newer Redis)
yum install -y https://rpms.remirepo.net/enterprise/remi-release-$(rpm -E %rhel).rpm

# Install Redis (latest stable, e.g., 7.x)
yum --enablerepo=remi install -y redis

Note: If you want a specific version, use yum --enablerepo=remi install redis70 redis70-redis etc.

3. Enable & Start Redis Service

systemctl enable redis
systemctl start redis
systemctl status redis   # should show "active (running)"

4. Secure Redis (Basic Hardening)

Edit /etc/redis.conf (or /etc/redis/redis.conf on some distros):

vi /etc/redis.conf

Make these changes:

# Bind to localhost only (or specific IP if needed)
bind 127.0.0.1

# Require password
requirepass YourStrongPasswordHere

# Disable dangerous commands (optional)
rename-command CONFIG ""

Restart Redis:

systemctl restart redis

5. Install PHP Redis Extension via EasyApache 4 (EA4)

Option A: WHM GUI (Recommended for cPanel admins)

  1. Log into WHMEasyApache 4
  2. Click Customize
  3. Go to PHP Extensions tab
  4. Search for redis
  5. Check:
  • ea-phpXX-phperedis (replace XX with your PHP version, e.g., ea-php81-phperedis)
  1. Click ReviewProvision

Option B: Command Line (if you prefer CLI)

# Example for PHP 8.1
yum install -y ea-php81-php-redis

# For other versions: ea-php74-php-redis, ea-php80-php-redis, etc.

Verify installation:

php -m | grep -i redis
# Should output: redis

6. Enable Redis Object Cache in WordPress (Optional but Common)

If using WordPress:

  1. Install Redis Object Cache plugin (by Till Krüss)
  2. Add to wp-config.php:
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_PASSWORD', 'YourStrongPasswordHere');
define('WP_REDIS_DATABASE', 0);
  1. Enable in WP Admin → Settings → Redis

7. Test Redis Connection via PHP

Create redis-test.php in a domain’s public_html:

<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->auth('YourStrongPasswordHere'); // remove if no password

$redis->set('test_key', 'Hello Redis!');
echo $redis->get('test_key'); // Should print: Hello Redis!
?>

Visit: https://yourdomain.com/redis-test.php

8. (Optional) Install Redis CLI Tools & phpRedisAdmin

# Redis CLI is already installed with redis package

# phpRedisAdmin (web GUI)
composer create-project -s dev erik-dubbelboer/php-redis-admin /usr/local/cpanel/base/frontend/cpanel/phpRedisAdmin

Then access via: https://yourserver:2087/phpRedisAdmin (secure with .htaccess)

9. Firewall (if firewalld or CSF is active)

# Allow only localhost (recommended)
# No port opening needed externally

# If you must allow remote:
firewall-cmd --permanent --add-port=6379/tcp
firewall-cmd --reload

Never expose Redis publicly without TLS or VPN!

Summary Checklist

StepDone?
Update system
Install Redis server
Enable & start service
Secure redis.conf
Install ea-phpXX-php-redis
Test PHP connection
(Optional) WordPress cache

You’re done! Redis is now running and integrated with PHP on your cPanel server.

Need Redis 7 + PHP 8.3?

Use Remi’s modular repos:

dnf module reset php
dnf module install php:remi-8.3
yum --enablerepo=remi install redis ea-php83-php-redis

Tags: ,