Created
May 17, 2016 22:01
-
-
Save carltondickson/62977cee8ea32c6ce594eaa60524292b to your computer and use it in GitHub Desktop.
Install and Configure Redis on Ubuntu 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04 | |
# Use at your own risk | |
sudo apt-get update | |
sudo apt-get install build-essential tcl | |
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 | |
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 | |
[Unit] | |
Description=Redis In-Memory Data Store | |
After=network.target | |
[Service] | |
User=redis | |
Group=redis | |
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf | |
ExecStop=/usr/local/bin/redis-cli shutdown | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target | |
# 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 | |
redis-cli | |
ping | |
# PONG response | |
set test "It's working!" | |
get test | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment