Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install and Configure Redis on Ubuntu 16.04
# From
# Use at your own risk
sudo apt-get update
sudo apt-get install build-essential tcl
cd /tmp
curl -O
tar xzvf redis-stable.tar.gz
cd redis-stable
make test
sudo make install
sudo mkdir /etc/redis
sudo cp /tmp/redis-stable/redis.conf /etc/redis
# /etc/redis/redis.conf changes
sudo nano /etc/redis/redis.conf
# In the file, find the supervised directive. Currently, this is set to no. Since we are running an operating system that uses the systemd init system, we can change this to systemd:
supervised systemd
# Next, find the dir directory. This option specifies the directory that Redis will use to dump persistent data. We need to pick a location that Redis will have write permission and that isn't viewable by normal users.
dir /var/lib/redis
sudo nano /etc/systemd/system/redis.service
# /etc/systemd/system/redis.service
Description=Redis In-Memory Data Store
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
# Redis users, group and directories
sudo adduser --system --group --no-create-home redis
sudo mkdir /var/lib/redis
sudo chown redis:redis /var/lib/redis
sudo chmod 770 /var/lib/redis
# Start and test redis
sudo systemctl start redis
sudo systemctl status redis
# PONG response
set test "It's working!"
get test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment