Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install Redis and the PHP Redis Extension on a cPanel Server

This guide shows you how to install the Redis cache on a cPanel server and connect PHP to it.

Website Management2 min read12 steps5 screenshots
Note: This guide needs root access. VPS and dedicated server customers have it.

What is Redis?

Redis is a fast storage tool that keeps data in memory. Websites use it as a cache. A cache is like a notepad of answers you use a lot, so you do not look them up again. This makes a site faster.

PHP cannot talk to Redis alone. It needs the PHP Redis extension. An extension is a small add-on for PHP.

Before you start

  • Take a backup or snapshot of your server.
  • Connect with SSH as root. SSH lets you type commands on your server. Your login details are in your welcome email.
  • These commands fit AlmaLinux, CentOS or Rocky Linux. Newer systems work in a similar way.

Install the Redis server

  1. Install Redis.
    dnf install redis -y
    This downloads and installs Redis. On older systems use yum instead of dnf.
  2. Start it and make it start at boot.
    systemctl enable --now redis
  3. Test it.
    redis-cli ping
    If Redis works, it replies PONG.
Warning: Keep Redis listening on the local address only (127.0.0.1). Open to the internet, anyone could read your data. Check the bind line in /etc/redis/redis.conf or /etc/redis.conf.

Install the PHP extension

  1. Log in to WHM with your root login.
    Screenshot: Log in to WHM with your root login.
  2. Search for EasyApache 4 and open it.
  3. Click Customize under your current profile.
  4. Open PHP Extensions.
    Screenshot: Open PHP Extensions .
    Screenshot: Open PHP Extensions .
  5. Search for redis. Switch it on for each PHP version your sites use. The package name looks like ea-php82-php-redis.
    Screenshot: Search for redis . Switch it on for each PHP version your sites use. The package name look
    Screenshot: Search for redis . Switch it on for each PHP version your sites use. The package name look
  6. Click Next until the review page, then click Provision.
  7. Wait until it finishes. The web server restarts for a moment.

Check it works

  1. In SSH, run this for your PHP version.
    /opt/cpanel/ea-php82/root/usr/bin/php -m | grep -i redis
    This prints redis if the extension is loaded. Change ea-php82 to match your version.
  2. Now set your app to use Redis. WordPress cache plugins, for example, ask for host 127.0.0.1 and port 6379.

Quick recap

  • Redis is a memory cache that speeds up sites.
  • Install the server with your package manager and start it.
  • Add the redis extension in WHM with EasyApache 4.
  • Keep Redis on 127.0.0.1 only.
  • Test with redis-cli ping and php -m.