Redis stands for Remote DIctionary Server and it is a key-value NoSQL database. Almost all languages including PHP have Redis bindings. In this guide, we will show you how to install Redis server and Redis PHP extension on a cPanel based servers so you can use Redis as a cache backend for your WordPress, Laravel, Drupal or any other PHP based application.
Table of Contents
1. Install Redis server
Redis is not available in the default CentOS repositories, so we need to enable the EPEL repository and install the Redis package from there.
2. Install the EPEL Repository on CentOS 6
To install the EPEL repository please run the following command:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
3. Install the Redis Package Using Yum
Once the repository is enabled, you can install the redis package using Yum:
sudo yum install redis
4. Start and Configure the Redis service
Start the Redis service and enable it to start on boot with the following commands:
service redis restart chkconfig --level 345 redis on
5. Install the EPEL Repository on CentOS 7
Same as with CentOS 6 first install the EPEL repository:
yum install epel-release
Once the repository is enabled, install the Redis package using Yum:
yum install redis
Start the Redis service and enable it to start on boot with the following commands:
systemctl restart redis systemctl enable redis
6. Install Redis PHP extension
Redis PHP extension is not available in EasyApache so we will install the Redis PHP extension using the pecl command. We will also enable Igbinary support which is a drop in replacement for the standard PHP serializer.
7. Install the Redis PHP Extension EasyApache 3
To install the Redis PHP extension issue the following command:
yes | pecl install igbinary igbinary-devel redis
once the build process is completed, verify the installation using the following command:
php -m | grep redis
and you should see redis
, if there is no output, it means that Redis extension is not installed/loaded.
8. Install the Redis PHP Extension EasyApache 4
EasyApache 4 supports multiple versions of PHP so we need to install the Redis PHP extension on each PHP version.
Run the following commands to install and enable the Redis PHP extension on each PHP version you have installed on your server:
9. Install and Enable the Redis PHP Extension on PHP 5.4
yes | /opt/cpanel/ea-php54/root/usr/bin/pecl install igbinary igbinary-devel redis /opt/cpanel/ea-php54/root/usr/bin/php -m | grep redis
10. Install and Enable the Redis PHP Extension on PHP 5.5
yes | /opt/cpanel/ea-php55/root/usr/bin/pecl install igbinary igbinary-devel redis /opt/cpanel/ea-php55/root/usr/bin/php -m | grep redis
11. Install and Enable the Redis PHP Extension on PHP 5.6
yes | /opt/cpanel/ea-php56/root/usr/bin/pecl install igbinary igbinary-devel redis /opt/cpanel/ea-php56/root/usr/bin/php -m | grep redis
12. Install and Enable the Redis PHP Extension on PHP 7.0
yes | /opt/cpanel/ea-php70/root/usr/bin/pecl install igbinary igbinary-devel redis /opt/cpanel/ea-php70/root/usr/bin/php -m | grep redis
13. Install and Enable the Redis PHP Extension on PHP 7.1
yes | /opt/cpanel/ea-php71/root/usr/bin/pecl install igbinary igbinary-devel redis /opt/cpanel/ea-php71/root/usr/bin/php -m | grep redis
That’s it. You have successfully installed Redis server and Redis PHP extension on your cPanel VPS
Installing Redis and Redis PHP on cPanel is an easy task if you have a VPS cPanel Hosting with us. Feel free to ask our expert Linux Administrators to install Redis and Redis PHP on cPanel for you, and it will be taken care of immediately. They are available 24×7, so you can get the help you need at any time.
PS. Feel free to share this blog on how to Install Redis and Redis PHP on cPanel, post if you liked it by using the social network shortcuts – you can also leave a comment instead, found under the share buttons.
is it possible on shared hosting ?
It is not possible to install it if you are on a shared hosting.
The problem with this is.
Redis is common for all the cPanel accounts on the same server.
This approach will not work in multi website or multi cPanel account on the same server. As all of the are accessing the same Redis.
Can you please share the steps for the environment, where there are multiple website or multiple cPanel account hosted on the same server and how can they have access to private que for each cPanel account?