How to install PHP pecl redis extension on cPanel with PHP 5.6 / PHP 7.0
Redis is a server that provides a key/value store. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.You can find more details about Redis on the Redis website. To interact with the Redis server from your PHP scripts (client-server communication), you need to install PHP pecl Redis extension.
Install PHP pecl redis extension on cPanel with PHP 5.6/PHP 7.0
In this article I will show you how to install PHP pecl redis extension on cPanel 58 with PHP 5.6/ PHP 7.0. So, I believe you have already setup your Redis server. If not, please refer the following link to download and setup the Redis server.
Here, I am installing the Redis PHP PECL extension on a cPanel 58 server with EasyApache 4.
You can directly install Redis PHP PECL module from “WHM >> Software >> Module Installers” page for PHP 7.0.
However, if you try to install the Redis PHP PECL extension 3.0 on the server for PHP 5.6, the following error will pop up.
pecl/redis requires PHP (version >= 7.0.0, version <= 7.1.0, excluded versions: 6.0.0), installed version is 5.6.25 No valid packages found install failed
It says you require atleast PHP 7.0 for installing Redis PHP pecl 3.0 extension.
So, the solution is to manually compile and install an older version of PECL redis extension using phpize command. Please follow the steps given below to achieve this.
cd /usr/local/src/ wget https://pecl.php.net/get/redis-2.2.8.tgz tar zxpf redis* cd redis* /opt/cpanel/ea-php56/root/usr/bin/phpize ./configure --with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config make make install
Once the installation went well, please don’t forget to add the following line to the PHP 5.6 php.ini configuration.
This will load Redis extension on your server. You can verify it using the command given below.
php -m | grep -i redis
It will show the redis extension. That’s it. We are done.
If you face any issues during the setup, please feel free to mail me or leave a comment below.