This article provides a guide for how to install Redis and Redis PHP extension for cPanel server.
How to Install Redis and Redis PHP extension for cPanel Server
To install Redis and Redis PHP extension for cPanel server, follow the steps below:
- Login via SSH as root user.
- Run the following commands:
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
- Now run the following:
cd ~ wget -O redis.tgz https://pecl.php.net/get/redis tar -xvf redis.tgz rm -f redis.tgz cd ~/redis* for phpver in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do /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 done /scripts/restartsrv_httpd /scripts/restartsrv_apache_php_fpm
- The redis package and PHP extensions should now be installed. To check, run the following command:
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
- If successful, the output will be similar:
CentOS 8/AlmaLinux 8/Rocky Linux 8
- For CentOS/AlmaLinux/Rocky Linux 8 cPanel servers, adjust the command as follows:
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-8.rpm dnf -y install redis --enablerepo=remi --disableplugin=priorities systemctl enable redis systemctl start redis
- Followed by:
cd ~ wget -O redis.tgz https://pecl.php.net/get/redis tar -xvf redis.tgz rm -f redis.tgz cd ~/redis* for phpver in $(whmapi1 php_get_installed_versions|grep -oE '\bea-php.*') ; do /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 done /scripts/restartsrv_httpd /scripts/restartsrv_apache_php_fpm
That's it. You now know how to install Redis and Redis PHP extensions on cPanel server.