DEV Community

Teddy Zugana
Teddy Zugana

Posted on

2 1

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:

CentOS/RHEL 7

yum install epel-release
Enter fullscreen mode Exit fullscreen mode

CentOS/RHEL 6

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
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.

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>

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more