Here is how to install Redis daemon on a cPanel/WHM server and add the Redis PHP extension to each EasyApache PHP version.
Step 1. Install Redis daemon:
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum -y install redis --enablerepo=remi --disableplugin=priorities
systemctl enable redis
systemctl start redis
Step 2. Install Redis PHP extension to each EasyApache PHP version:
for phpver in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do
cd ~
wget -O redis.tgz https://pecl.php.net/get/redis
tar -xvf redis.tgz
cd ~/redis-* || exit
/opt/cpanel/"$phpver"/root/usr/bin/phpize
./configure --with-php-config=/opt/cpanel/"$phpver"/root/usr/bin/php-config
make clean && make install
echo 'extension=redis.so' > /opt/cpanel/"$phpver"/root/etc/php.d/redis.ini
rm -rf ~/redis*
done
Allow a few minutes to install Redis extension to each PHP version:
Step 3. Verify that the Redis extension has been added:
for phpver in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do
echo "PHP $phpver" ; /opt/cpanel/"$phpver"/root/usr/bin/php -i |grep "Redis Support"
done
The output should be: