Skip to content

Instantly share code, notes, and snippets.

@manwithsteelnerves
Forked from clzola/install-redis.sh
Last active July 29, 2020 06:19
Show Gist options
  • Save manwithsteelnerves/f6a94fa7eb162f744129c97d4eede15b to your computer and use it in GitHub Desktop.
Save manwithsteelnerves/f6a94fa7eb162f744129c97d4eede15b to your computer and use it in GitHub Desktop.
Bash script for installing Redis on Ubuntu 16.04
#!/bin/bash
# Install the Build and Test Dependencies
apt-get update
apt-get install -y curl build-essential tcl
# Download and Extract the Source Code
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
cd redis-stable
# Build and Install Redis
make
make test
make install
# Configure Redis
mkdir /etc/redis
cp /tmp/redis-stable/redis.conf /etc/redis
sed -i "s/^supervised no/supervised systemd/" /etc/redis/redis.conf
sed -i "s/^dir \.\//dir \/var\/lib\/redis/" /etc/redis/redis.conf
# Create a Redis systemd Unit File
wget -O /etc/systemd/system/redis.service https://gist.githubusercontent.com/manwithsteelnerves/f6a94fa7eb162f744129c97d4eede15b/raw/995efb596e09fd08e24a9b3bdc8555f5034f9bf9/redis.service
# Create the Redis User, Group and Directories
adduser --system --group --no-create-home redis
mkdir /var/lib/redis
chown redis:redis /var/lib/redis
chmod 770 /var/lib/redis
# Start Redis
systemctl start redis
# Enable Redis to Start at Boot
systemctl enable redis
# Clean
rm -rf /tmp/redis-stable
rm /tmp/redis-stable.tar.gz
[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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment