DEV Community

Teddy Zugana
Teddy Zugana

Posted on

Install Redis Cache Server on CentOS 7/6

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.

Redis is an in-memory data structure store, used as a database server, cache, and message broker. It also provides a PHP module for communication between PHP script with the Redis server. Redis is written in C programming language.

This tutorial will help you with the installation of the Redis server along with PHP Redis PHP extensions on a CentOS 7/6 server.

Redis packages are not available under default yum repositories. You need to enable EPEL yum repository on your server first. Execute below command to enable:


yum install epel-release
Enter fullscreen mode Exit fullscreen mode


rpm -Uvh
Enter fullscreen mode Exit fullscreen mode

Install Redis Server

Now, You can use the yum package manager to install the Redis server on a VPS. Execute command to install Redis on your systems:

yum install redis

After successfully installation start Redis service and enable auto-start on system reboot.


systemctl enable redis
systemctl start redis


chkconfig redis on
service redis restart

Centos 6 :

chkconfig redis on

Centos 7 :

systemctl enable redis

Install Redis PHP extension

We assume you already have PHP installed on your system.

cd /root
git clone
cd phpredis
make clean
./configure --with-php-config=/opt/alt/php70/usr/bin/php-config
make install

Replace red higlighted config with :

For php selector version :
php 5.6

./configure --with-php-config=/opt/alt/php56/usr/bin/php-config

php 7.0

./configure --with-php-config=/opt/alt/php70/usr/bin/php-config

php 7.1

./configure --with-php-config=/opt/alt/php71/usr/bin/php-config

php 7.2

./configure --with-php-config=/opt/alt/php72/usr/bin/php-config

Add this line to php.ini navigate to php selector >> Edit php.ini

(under the php version you installed redis php )

**if you’re using custom php.ini add this line to it also

Test Connection to Redis Server

Use redis-cli tool to verify the connection between the Redis server and redis-cli.

redis-cli> ping

Top comments (0)