Posted by & filed under Linux, Redis.

If you’d like to have the most recent version of Redis installed on your Debian machine, follow along with this guide. Unfortunately, the process of installing it is not as easy as `sudo apt-get install redis`, which you probably already knew since you’re reading this. The current version of Redis, at the time of me writing this, is 2.6.13. Go to the website and copy the download link and be sure to change the version in the URL below:

# Install the required tools to build the source
sudo apt-get install build-essential
# Download and extract the files
tar -xzf redis-2.6.13.tar.gz
cd redis-2.6.13
# Compile
make install

Now that you’ve got it “installed”, you’re going to want to make it a Debian service (so that it can run on startup, and you can use commands like `sudo service redis start`):

# Create a user account for Redis
sudo adduser --system --no-create-home --disabled-login --disabled-password --group redis
# Make a writable log file
sudo touch /var/log/redis.log
sudo chown redis:redis /var/log/redis.log
sudo chmod u+w /var/log/redis.log
# Make an init script
cd /etc/init.d/
wget -O redis
sudo chmod u+x redis
sudo update-rc.d -f redis defaults
# Make a place to store your database
sudo mkdir /var/redis
sudo chown redis:redis /var/redis
sudo chmod u+xw /var/redis

Next, you’ll want to edit the configuration script. Do the following:

sudo mkdir /etc/redis
sudo touch /etc/redis/redis.conf
sudo chown redis:redis -R /etc/redis/
sudo vim /etc/redis/redis.conf

Here is what I use for my redis.conf file:

daemonize yes
pidfile /var/run/
logfile /var/log/redis.log
port 6379
# bind
# unixsocket /tmp/redis.sock
timeout 300
loglevel verbose
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
dbfilename dump.rdb
dir /var/redis/
# requirepass foobared

Once that’s all done, run the following to make sure everything was installed properly:

$ sudo service redis start
$ redis-cli

If you see an error when the server is starting, or an error after running the CLI script that it cannot connect, something went awry. Leave a comment and I’ll be sure to lend a hand.

Thomas Hunter II

Thomas is the author of Advanced Microservices and a prolific public speaker with a passion for reducing complex problems into simple language and diagrams. His career includes working at Fortune 50's in the Midwest, co-founding a successful startup, and everything in between.
(Visited 4,958 times, 17 visits today)


  • johan

    Thanks for the guide, raspberry pi redis.

  • Thomas,
    using: redis-2.8.0-rc3

    $ sudo redis-server
    # Creating Server TCP listening socket *:6379: unable to bind socket

    $ sudo redis-server /etc/redis/redis.conf

    but ps ax does not list redis-server

    sudo apt-get install redis-server is now possible, but out of date and more seriously was not keeping a log, and SAVE gave err
    ie works but all data is lost on reboot.

  • seunggu lee

    Thanks for the guide, raspberry pi redis.
    But my raspberry pi not working.

    $ sudo service redis start
    Could not connect to Redis at Connection refuese.

    how can i fix it?

  • Michael

    If you can’t get this to work, check the location of redis-server in the script. The pi does not always install into /user/bin. It can also go into /usr/local/bin.

  • Guzman Monne

    Thank you very much for this tutorial. I also had the same problem as Jonathan, and fix it changing the init script to /usr/local/bin as Michael posted

  • Great, thank you.
    Just two things:

    sudo wget

    And like Michael said:


  • alex

    I’m confused since you (and also redis webpage) doesn’t specify where to download redis, like if this doesn’t matter…
    I downloaded it in /home/myuser/Downloads/redis.xxxx/
    and when I made $make install it created a dir inside /home/myuser/Downloads/redis.xxxx/src/

    now in the entire guide you put steps as if magically linux should know where it was installed.

    when I did $sudo service redis start I got no notification, and server is not running, if I do $ps aux | grep redis I got nothing but the grep command in the processes list.

    what do you think could be problem ?

  • alex

    Ok, I got the idea, you need to edit:


    and change this line

    this is in case you have redis server and other clients inside /usr/local/bin.

    @brunto mentioned but he was not specific with details.
    thanks for tutorial.

  • tane

    i followed the instructions and had this error
    # redis-cli
    Could not connect to Redis at Connection refused
    not connected>

    i fixed it as by changing the init script as it was shown by Alex .
    thanks you all for your comments