Skip to content

Instantly share code, notes, and snippets.

@wwwpro
Forked from dstroot/install-redis.sh
Last active August 29, 2015 14:05
Show Gist options
  • Save wwwpro/06b3f473a150521b294f to your computer and use it in GitHub Desktop.
Save wwwpro/06b3f473a150521b294f to your computer and use it in GitHub Desktop.
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
###############################################
echo "*****************************************"
echo " 1. Prerequisites: Install updates, set time zones, install GCC and make"
echo "*****************************************"
#yum -y update
#ln -sf /usr/share/zoneinfo/America/Los_Angeles \/etc/localtime
#yum -y install gcc gcc-c++ make
echo "*****************************************"
echo " 2. Download, Untar and Make Redis Stable"
echo "*****************************************"
cd /usr/local/src
wget http://download.redis.io/redis-stable.tar.gz
tar xzf redis-stable.tar.gz
rm -f redis-stable.tar.gz
cd redis-stable
make
echo "*****************************************"
echo " 3. Create Directories and Copy Redis Files"
echo "*****************************************"
mkdir /etc/redis /var/lib/redis
cp src/redis-server src/redis-cli /usr/local/bin
echo "*****************************************"
echo " 4. Configure Redis.Conf"
echo "*****************************************"
echo " Edit redis.conf as follows:"
echo " 1: ... daemonize yes"
echo " 2: ... bind 127.0.0.1"
echo " 3: ... dir /var/lib/redis"
echo " 4: ... loglevel notice"
echo " 5: ... logfile /var/log/redis.log"
echo "*****************************************"
sed -e "s/^daemonize no$/daemonize yes/" -e "s/^# bind 127.0.0.1$/bind 127.0.0.1/" -e "s/^dir \.\//dir \/var\/lib\/redis\//" -e "s/^loglevel verbose$/loglevel notice/" -e "s/^logfile stdout$/logfile \/var\/log\/redis.log/" redis.conf > /etc/redis/redis.conf
echo "*****************************************"
echo " 5. Download init Script"
echo "*****************************************"
wget https://gist.github.com/wwwpro/7435c3ca128f8458a40a/raw/e64b4b8ad7d38676f7e7f70b24f3f004b4f10b74/redis
echo "*****************************************"
echo " 6. Move and Configure Redis-Server"
echo "*****************************************"
mv redis /etc/init.d/
chmod 755 /etc/init.d/redis
echo "*****************************************"
echo " 7. Auto-Enable redis"
echo "*****************************************"
chkconfig --add redis
chkconfig --level 345 redis on
echo "*****************************************"
echo " 8. Start Redis Server"
echo "*****************************************"
service redis start
echo "*****************************************"
echo " Complete!"
echo " You can test your redis installation using the redis console:"
echo " $ src/redis-cli"
echo " redis> set foo bar"
echo " OK"
echo " redis> get foo"
echo " bar"
echo "*****************************************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment