Redis is an open source , in-memory data structure store, used as a database, cache and message broker.  Redis is built to provide the highest throughput (millions of operations/second) at the lowest latencies (< 1ms), with the least system resources. Redis is primarily used for caching to improve website and webserver performance. With redis, there is a server installation that needs to be done, and if you are using it with php, there is an extension that is needed to allow php to speak with the redis server.

To install redis you need root level access to SSH, or to your terminal in WHM.

 

Step 1 – Install the epel repository

First we need to add the epel repository, as the redis package is not available within the default repositories. To add the repo Run the following commands:

Centos/RHEL v7

yum install epel-release

Centos/RHEL v6

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Step 2 – Install the Redis Server

If the repository installation was successful, you can now use yum to install the Redis server

yum install redis

Step 3 – Enable and Start the Redis Server

Now that the server is installed, we need to start it up, and make sure that it starts up if the server reboots.

CentOS/RHEL v7

systemctl enable redis
systemctl start redis

CentOS/RHEL v6

chkconfig redis on
service redis restart

Step 4 – Install Redis PHP extension

Now that the redis server is up and running, we can install the php extension, so your php site can talk to the server and enjoy all the benefits from redis. To install the correct package, we need to determine if you are running Easy Apache 3 or Easy Apache 4.

Check Version of Easy apache

Log into WHM and search for “Easy Apache” in the top search field. If you see Easy Apache 4 only, then you are likely running EA4. If you see both options, then you are likely still utilizing EA3 and should upgrade your systems, as this is no longer supported by cpanel. If you need to use this with multiple versions of PHP, you can install for each version that you need on EA4.

Install Redis PHP extensions for EA4

PHP 5.6

/opt/cpanel/ea-php56/root/usr/bin/pecl install igbinary igbinary-devel redis 
#Check your work:
/opt/cpanel/ea-php56/root/usr/bin/php -m | grep redis

PHP 7.0

/opt/cpanel/ea-php70/root/usr/bin/pecl install igbinary igbinary-devel redis 
#Check your work:
/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 
#Check your work:
/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 
#Check your work:
/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 
#Check your work:
/opt/cpanel/ea-php73/root/usr/bin/php -m | grep redis

Install Redis PHP extensions for EA3

pecl install igbinary igbinary-devel redis
#check your work:
php -m | grep redis

 

You should now be all set with the redis server and php extension installation. You should now be able to direct your sites caching agent to utilize redis and speed things up on your site.

Check out these related articles:


Leave a Reply

Your email address will not be published. Required fields are marked *