loading...

Install Redis Cache Server on CentOS 7/6

kevinmel2000 profile image Teddy Zugana ・2 min read

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:

CentOS/RHEL 7

yum install epel-release

CentOS/RHEL 6

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

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.

CentOS/RHEL 7

systemctl enable redis
systemctl start redis

CentOS/RHEL 6

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 https://github.com/phpredis/phpredis.git
cd phpredis
make clean
/opt/alt/phpVV/usr/bin/phpize
./configure --with-php-config=/opt/alt/php70/usr/bin/php-config
make
make install

Replace red higlighted config with :

For php selector version :
php 5.6

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

php 7.0

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

php 7.1

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

php 7.2

/opt/alt/php72/usr/bin/phpize
./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 )

extension=redis.so

**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

127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

Discussion

pic
Editor guide