How to install Redis on a Centos 6.4 Server

From Brian Nelson Ramblings
Revision as of 12:57, 3 September 2013 by Brian (Talk | contribs) (Add a second instance of Redis)

Jump to: navigation, search

How to install redis on a Centos Server

yum install redis
service redis start
chkconfig redis on

Now verify its set to start at boot

chkconfig --list redis
redis           0:off   1:off   2:on    3:on    4:on    5:on    6:off

Now that was pretty simple, but lets say you want to add a second instance to your server on a different port

Add a second instance of Redis

cp redis.conf redis2.conf && cp /etc/init.d/redis /etc/init.d/redis2

Change

vim /etc/init.d/redis2
pidfile="/var/run/redis/redis.pid" to pidfile="/var/run/redis/redis2.pid"
REDIS_CONFIG="/etc/redis.conf" to REDIS_CONFIG="/etc/redis2.conf"

Change

vim /etc/redis2.conf
port 6379 to port 6380
unixsocket /tmp/redis.soc to unixsocket /tmp/redis2.sock
service redis2 start

Let also make this instance start up on boot

chkconfig redis2 on

Now verify its set to start at boot

chkconfig --list redis2
redis2          0:off   1:off   2:on    3:on    4:on    5:on    6:off

To install a web interface for redis

cd /downloads/
git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
cd phpRedisAdmin/includes
cp config.sample.inc.php config.inc.php

Make sure the setting are correct

vim config.inc.php

Lets add the RedisAdmin configuration file to Apache

vim /etc/httpd/conf.d/redisadmin.conf

Now add the following

#
#  Web Interface for RedisAdmin
# 

<Directory "/downloads/phpRedisAdmin/">
  Order Deny,Allow
  Deny from all
  Allow from 127.0.0.1
  Allow from <your ipaddress>
</Directory>

Alias /redisAdmin /downloads/phpRedisAdmin
Alias /redisadmin /downloads/phpRedisAdmin

View your RedisAdmin Section

http://example.tld/redisadmin