Here is a complete guide for installing and configuring Memcached and Redis on cPanel running AlmaLinux 9 or CloudLinux 9, tailored for server optimization and performance enhancement.
🔧 Step 1: Enable EPEL Repository
yum install epel-release -y
This allows access to additional packages like Redis and Memcached not available in the base repos.
🔁 Step 2: Install and Configure Redis
yum install redis -y
Start and Enable Redis
systemctl start redis
systemctl enable redis
Check Redis Status
systemctl status redis
You should see
Active: active (running)
if Redis is working properly.
Benchmark Redis
Optional, but useful for a quick performance test:
redis-benchmark -q -n 1000
💾 Step 3: Install Memcached
yum install memcached -y
Start Memcached
systemctl start memcached
systemctl enable memcached
Check Memcached Status
systemctl status memcached
You should see
Active: active (running)
if Memcached is working.
⚙️ Step 4: Configure Memcached
Edit the configuration file:
nano /etc/sysconfig/memcached
Replace or confirm the following values:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1 -U 0"
Explanation:
-l 127.0.0.1
restricts Memcached to localhost (secure).-U 0
disables UDP (recommended for security).- Adjust
CACHESIZE
depending on available RAM.
Restart Memcached to apply changes:
systemctl restart memcached
🔐 Notes for cPanel Servers
- These services do not interfere with cPanel or WHM.
- For PHP-based applications (e.g., WordPress, Magento), make sure to install corresponding PHP extensions:
yum install ea-phpXX-php-pecl-redis ea-phpXX-php-pecl-memcached
ReplaceXX
with your desired PHP version (e.g.,81
).
You can verify extensions are loaded using:
php -m | grep -E 'redis|memcached'
✅ Final Checklist
Task | Status |
---|---|
EPEL installed | ✅ |
Redis installed & running | ✅ |
Memcached installed & running | ✅ |
Memcached config updated | ✅ |
PHP extensions installed | ✅ |