Skip to content

Instantly share code, notes, and snippets.

@someburner
Forked from iJackUA/install-redis-ubuntu.sh
Last active March 10, 2022 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save someburner/2f609ffe7b85fb611f39aeb65294937c to your computer and use it in GitHub Desktop.
Save someburner/2f609ffe7b85fb611f39aeb65294937c to your computer and use it in GitHub Desktop.
Install Redis from source (Ubuntu)
#!/bin/bash
if [ "$(whoami)" != "root" ]; then
echo "ERROR : Run script as Root (sudo !!) please"
exit 1
fi
read -e -p "Redis version to be installed (change if needed) : " -i "2.8.2" VERSION
echo 'Installing redis v.'$VERSION' ... '
# installing build essentials if it is missing
apt-get install build-essential
wget http://download.redis.io/releases/redis-$VERSION.tar.gz
tar xzf redis-$VERSION.tar.gz
cd redis-$VERSION
make
make install prefix=/usr/local/bin/
cp redis.conf /etc/redis.conf
cd ..
rm redis-$VERSION -R
rm redis-$VERSION.tar.gz
# create user and autostart
useradd -r -s /bin/false redis
wget -O /etc/init.d/redis-server https://gist.github.com/iJackUA/5336459/raw/4d7e4adfc08899dc7b6fd5d718f885e3863e6652/redis-server-for-init.d-startup
touch /var/run/redis.pid
chown redis:redis /var/run/redis.pid
chmod 755 /etc/init.d/redis-server
# add overcommit memory change (if not already present)
echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
sysctl vm.overcommit_memory=1
# UNCOMMENT IF NEEDED to do autostart
# update-rc.d redis-server defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment