Ubuntu – How to set up redis to run automatically on the Ubuntu machine the way it does on mac

mac-osxredisrubyUbuntu

On my (new) mac I can use spork and redis seems to be already running.

However on my Ubuntu system (11.10) I get

Connection refused - 
Unable to connect to Redis on localhost:6379 (Errno::ECONNREFUSED)

I can get around this with redis-server which start redis as a foreground process in that window.

How can I have redis-server always be running on my Ubuntu ? i.e. through reboots

I thought about putting redis-server in my .bashrc but I don't want a new redis server started with each new terminal window. Could it go in my .bash_login ?

Best Answer

The trick is to put an init script in your /etc/init.d/ and then use the update-rc.d command to enable/disable it. I use a modified version of this init script. Also take a look at this post. Hope it points you to the right direction.