Redis is an in-memory data structure store, used as a database server, cache and message broker. It also provides a PHP module for communication between PHP scripts and the Redis server.
This guide will help you with the installation of the Redis server and binding with PHP using Redis PHP extensions on a cPanel server.
Step 1 – Prerequisites
Redis packages are not available under default yum repositories. You need to enable EPEL yum repository on your server first. Execute the following command to enable EPEL:
### CentOS/RHEL 7 yum install epel-release
Step 2 – Install Redis Server
Next, install Redis using yum
yum install redis
After successfully installing, start Redis service and enable to auto-start on system reboot.
### CentOS/RHEL 7 systemctl enable redis systemctl start redis
Redis server is up and is running on your system.
Step 3 – Install Redis PHP extension
NOTE: Answer (default) NO to all additional caching options while running these commands
PHP 7
/opt/cpanel/ea-php70/root/usr/bin/pecl install igbinary igbinary-devel redis
/opt/cpanel/ea-php70/root/usr/bin/php -m | grep redis
PHP 7.1
/opt/cpanel/ea-php71/root/usr/bin/pecl install igbinary igbinary-devel redis
/opt/cpanel/ea-php71/root/usr/bin/php -m | grep redis
PHP 7.2
/opt/cpanel/ea-php72/root/usr/bin/pecl install igbinary igbinary-devel redis
/opt/cpanel/ea-php72/root/usr/bin/php -m | grep redis
PHP 7.3
/opt/cpanel/ea-php73/root/usr/bin/pecl install igbinary igbinary-devel redis
/opt/cpanel/ea-php73/root/usr/bin/php -m | grep redis
PHP 7.4
/opt/cpanel/ea-php74/root/usr/bin/pecl install igbinary igbinary-devel redis
/opt/cpanel/ea-php74/root/usr/bin/php -m | grep redis
PHP 8
/opt/cpanel/ea-php80/root/usr/bin/pecl install igbinary igbinary-devel redis
/opt/cpanel/ea-php80/root/usr/bin/php -m | grep redis
PHP 8.1
/opt/cpanel/ea-php81/root/usr/bin/pecl install igbinary igbinary-devel redis
/opt/cpanel/ea-php81/root/usr/bin/php -m | grep redis