Skip to content

Instantly share code, notes, and snippets.

@sonuame
Forked from clzola/install-redis.sh
Last active October 4, 2020 08:15
Show Gist options
  • Save sonuame/46a7704d93e189d2f4f01afee4c6fe02 to your computer and use it in GitHub Desktop.
Save sonuame/46a7704d93e189d2f4f01afee4c6fe02 to your computer and use it in GitHub Desktop.
Bash script for installing Redis on Ubuntu 18.04
#!/bin/bash -e
# cleanup old installation
rm -rf /etc/redis
rm -rf /var/lib/redis
rm $HOME/redis.sh
deluser --force --remove-home redis
# 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
rm -rf redis-stable
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
#create Redis.Conf file
wget -O /etc/redis/redis.conf https://gist.githubusercontent.com/sonuame/46a7704d93e189d2f4f01afee4c6fe02/raw/20b59be9b280cb74528c463f9cac3f0e129a95cd/redis.conf
# 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
# Clean
rm -rf /tmp/redis-stable
rm /tmp/redis-stable.tar.gz
cd $HOME/
echo "/usr/local/bin/redis-server /etc/redis/redis.conf" >> redis.sh
chmod 777 redis.sh
echo "Redis Installed successfully. Run redis.sh placed under home directory"
#!/bin/bash -e
# wget -O - http://dl.dropbox.com/u/11210438/flockonus-stack.sh | bash
# cleanup old installation
systemctl stop redis
systemctl disable redis
rm -rf /etc/redis
rm -rf /var/lib/redis
deluser --force --remove-home redis
# 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
rm -rf redis-stable
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
# Create a Redis systemd Unit File
wget -O /etc/systemd/system/redis.service https://gist.githubusercontent.com/sonuame/46a7704d93e189d2f4f01afee4c6fe02/raw/995efb596e09fd08e24a9b3bdc8555f5034f9bf9/redis.service
#create Redis.Conf file
wget -O /etc/redis/redis.conf https://gist.githubusercontent.com/sonuame/46a7704d93e189d2f4f01afee4c6fe02/raw/20b59be9b280cb74528c463f9cac3f0e129a95cd/redis.conf
# 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
systemctl daemon-reload
# 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
echo "Redis Installed and running successfully on port 6379"
bind 127.0.0.1
protected-mode no
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised auto
pidfile /var/run/redis_6379.pid
loglevel notice
databases 16
save 900 1
save 300 10
save 60 10000
dir /var/lib/redis
[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