Redis is an in-memory data structure store, used as database server, cache and message broker. It also provides PHP module for communication between PHP script with Redis server.
This guide will help you for the installation of Redis server and binding with PHP using Redis PHP extensions on a cPanel server.
Step 1 – Prerequisites
In order to use this tutorial, you must have root shell access of your WHM/cPanel server. Login to your server shell access using root account.
Redis packages are not available under default yum repositories. You need to enable EPEL yum repository on your server first. Execute below command to enable:
### CentOS/RHEL 7 yum install epel-release ### CentOS/RHEL 6 rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Step 2 – Install Redis Server
Now, You can use yum package manage to install Redis server packages by executing below command
yum install redis
After successfully installation start Redis service and enable to auto-start on system reboot.
### CentOS/RHEL 7 systemctl enable redis systemctl start redis ### CentOS/RHEL 6 chkconfig redis on service redis restart
Redis server is up and running on your system. Go to next step to enable Redis PHP extension on your cPanel server.
Step 3 – Install Redis PHP extension
In this step there are two option available based in the EasyApache version on your cPanel server. Follow one of below step:
cPanel with EasyApache 4
You can install Redis PHP extension for all installed PHP version on your system or install for the active version only. We recommend to install for all versions.
/opt/cpanel/ea-php56/root/usr/bin/pecl install igbinary igbinary-devel redis /opt/cpanel/ea-php56/root/usr/bin/php -m | grep redis
/opt/cpanel/ea-php70/root/usr/bin/pecl install igbinary igbinary-devel redis /opt/cpanel/ea-php70/root/usr/bin/php -m | grep redis
/opt/cpanel/ea-php71/root/usr/bin/pecl install igbinary igbinary-devel redis /opt/cpanel/ea-php71/root/usr/bin/php -m | grep redis
cPanel with EasyApache 3
If the cPanel is still running with EasyApache 3, Execute below commands to install Redis PHP extension on your system. Also check Redis module is enabled for PHP.
pecl install igbinary igbinary-devel redis php -m | grep redis
All done. Redis has been installed on your system along with the PHP extension.