Skip to content

Instantly share code, notes, and snippets.

@kwoktung
Forked from hackedunit/install-redis.md
Last active November 28, 2019 14:57
Show Gist options
  • Save kwoktung/ceb5a22dd8592dafd98149bffb6a1e3b to your computer and use it in GitHub Desktop.
Save kwoktung/ceb5a22dd8592dafd98149bffb6a1e3b to your computer and use it in GitHub Desktop.
Install and configure Redis on Ubuntu 16.04 with systemd
  1. Install pre-requisities

sudo apt-get install build-essential tcl

  1. Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
cd redis-stable
make
make test
sudo make install
  1. Configure Redis
sudo mkdir /etc/redis
sudo cp /tmp/redis-stable/redis.conf /etc/redis
sudo vim /etc/redis/redis.conf

In the file, change the supervised directive's value to systemd.

...
supervised systemd
...

Next, specify the working directory for Redis. This is the directory that Redis will use to dump persistent data. We can use /var/lib/redis

...
dir /var/lib/redis
...

Save and close the file.

  1. Configure systemd to start Redis on boot

sudo vim /usr/lib/systemd/system/redis.service

Copy the contents of this gist to the file, save and close.

  1. Create Redis user, group and directories
sudo adduser --system --group --no-create-home redis
sudo mkdir /var/lib/redis
sudo chown redis:redis /var/lib/redis
sudo usermod -d /var/lib/redis redis
sudo usermod -s /sbin/nologin redis
sudo chmod 770 /var/lib/redis
  1. Start the Redis service and set Redis to start on boot
sudo systemctl enable redis
sudo systemctl start redis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment