Redis as a Background Daemon

For installing Redis on ubuntu, refer my other post .

To run Redis as a Background Daemon, there is a script provided by Redis itself. Navigate to the utils folder where redis has been installed.

There will be a script called install_server.sh. To run redis as a background daemon, we need to execute the script as root. It will ask you set of question before making redis as background Daemon

# ./install_server

Welcome to the redis service installer This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]

Selecting default: 6379 Please select the redis config file name [/etc/redis/6379.conf]
Selected default – /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis6379.log]
Selected default – /var/log/redis
6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default – /var/lib/redis/6379
Please select the redis executable path [] ♦♦♦♦♦♦♦♦♦♦/redis-2.4.13/src/redis-server

Here we need to give the redis installation folder path along with src/redis-server

./installserver.sh: 149: ./installserver.sh: [[: not found Copied /tmp/6379.conf => /etc/init.d/redis6379
Installing service…
./install
server.sh: 163: ./installserver.sh: [[: not found ./installserver.sh: 168: ./installserver.sh: chkconfig: not found ./installserver.sh: 169: ./installserver.sh: chkconfig–level: not found /etc/init.d/redis6379: 1: /etc/init.d/redis_6379: -e: not found Starting Redis server…
Installation successful!

Now we are done with redis as background daemon.

To start redis execute the following command

$ sudo /etc/init.d/redis_6379 start

Starting Redis server…

Now redis server is up and running. We can verify it by running the redis client

$ src/redis-cli

redis 127.0.0.1:6379> ping

PONG

redis 127.0.0.1:6379>

To stop redis server, execute the following command

$ sudo /etc/init.d/redis_6379 stop

Stopping …

Redis stopped

Thats it we are done with running redis as background daemon. Now whether we start/restart the system, redis will run automatically.