CentOS 7 - Redis

If we want newer redis with streams support (and not old redis 3.x by default in epel repo), install & enable remi repo:

# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
# yum-config-manager --enable remi

Installation of Redis on standard port 6379:

# yum install redis -y
# systemctl start redis
# systemctl status redis
# systemctl enable redis

Test:

$ redis-cli ping
PONG

Adding redis suppor to php on client machine:

# yum -y install php-pecl-redis

Accessing from outside (e.g. local private network):

# vim /etc/redis.conf

...
bind 127.0.0.1 192.168.1.x
...

# systemctl restart redis

# firewall-cmd --zone=internal --add-port=6379/tcp --permanent
# firewall-cmd --reload

Creating redis server instance for different environment on different port

Environment name = test
Port = 6579

# mkdir /var/lib/redis_test
# chown redis.redis /var/lib/redis_test
# cp /etc/redis.conf /etc/redis_test.conf
# vim /etc/redis_test.conf
...
port 6579
...
pidfile /var/run/redis_6579.pid
...
logfile /var/log/redis/redis_test.log
...
dir /var/lib/redis_test

# chown redis.root /etc/redis_test.conf
# cp /usr/lib/systemd/system/redis.service /etc/systemd/system/redis_test.service
# vim /etc/systemd/system/redis_test.service
...
Description=Redis Test
...
ExecStart=/usr/bin/redis-server /etc/redis_test.conf --supervised systemd
ExecStop=/usr/libexec/redis-shutdown redis_test

# systemctl start redis_test
# systemctl status redis_test
# systemctl enable redis_test

Test:

$ redis-cli -p 6579 ping