Skip to content

Instantly share code, notes, and snippets.

@TomA-R
Last active May 9, 2018 01:09
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 TomA-R/b0d73d9e2a38674e91f18a24823543b8 to your computer and use it in GitHub Desktop.
Save TomA-R/b0d73d9e2a38674e91f18a24823543b8 to your computer and use it in GitHub Desktop.
Install Redis stable
#!/bin/bash
# Dependencies
yum install -y tcl
# Download and extract source code
cd /usr/local/src
wget http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
rm -f redis-stable.tar.gz
cd redis-stable
# Build and install Redis
make distclean
make
make install
# Since /usr/local/bin isn't always in $PATH, let's symlink
ln -s /usr/local/bin/redis-cli /usr/bin/redis-cli
# Copy and modify redis configuration file
mkdir -p /etc/redis /var/redis/data
chmod 770 /var/redis/data
cp redis.conf /etc/redis/redis.conf
sed -i "s/^bind .*/bind 127.0.0.1/" /etc/redis/redis.conf
sed -i "s/^daemonize .*/daemonize yes/" /etc/redis/redis.conf
sed -i "s/^logfile .*/logfile \"\/var\/log\/redis.log\"/" /etc/redis/redis.conf
sed -i 's/^dir .*/dir \/var\/redis\/data/' /etc/redis/redis.conf
# In our case, we'd rather write to Redis even if it can't persist to disk in the background, than just silently not write at all..
sed -i 's/^stop-writes-on-bgsave-error .*/stop-writes-on-bgsave-error no/' /etc/redis/redis.conf
# Service init script
wget https://raw.githubusercontent.com/edm-org/install-redis-amazon-linux-centos/master/redis-server
mv redis-server /etc/init.d
chmod 755 /etc/init.d/redis-server
# Create the redis user and group and set dir ownership+permissions
groupadd redis
adduser --system -g redis --no-create-home redis
chown redis:redis /var/redis/data
# Start Redis
service redis-server start
# Enable Redis to Start at Boot
chkconfig redis-server on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment