Skip to content

Instantly share code, notes, and snippets.

@mansurali901
Created September 5, 2017 06:34
Show Gist options
  • Save mansurali901/5e1b7a4d26efc9527039ce06213e1b38 to your computer and use it in GitHub Desktop.
Save mansurali901/5e1b7a4d26efc9527039ce06213e1b38 to your computer and use it in GitHub Desktop.
Setting Up Redis Server on Ubuntu 16.04 LTS
#!/bin/bash
# This script is written to install redis
# on Ubuntu Server 16.04 & 14.04 LTS
# Author Mansur Ul Hasan
# Email [email protected]
Configuration_Redis () {
echo "Configuration Started...!"
mkdir /etc/redis
cp /tmp/redis-stable/redis.conf /etc/redis
sed -i 's/#dir /dir /g' /etc/redis/redis.conf
echo "
[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
" >> /etc/systemd/system/redis.service
echo "Adding User for redis service"
adduser --system --group --no-create-home redis
echo "Data Directory for Redis"
mkdir -p /var/lib/redis
chmod 770 /var/lib/redis
echo "Starting Redis Service "
systemctl start redis
echo "Checking Redis Press Ctrl+c after result"
}
installation_proc () {}
echo "Initializing Installation process"
echo "Downloading Source Code"
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
echo "Download completed "
sleep 2
echo "Extracting Source Code"
tar xzvf redis-stable.tar.gz
cd redis-stable
make
make test
make install
# Calling Configuration Function
Configuration_Redis
}
PreReq () {
echo "Installing Pre-requisites for Redis"
apt-get update -y
apt-get install build-essential tcl -y
echo "Pre-requisites Installation Completed "
sleep 2
# Calling Installation Function
installation_proc
}
PreReq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment