Last active
November 16, 2015 16:17
-
-
Save Djuki/fb9834a82e7244bae43c to your computer and use it in GitHub Desktop.
Install redis as a service shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VER=3.0.5 | |
sudo apt-get update | |
# Install the required tools to build the source | |
sudo apt-get install build-essential | |
# Download and extract the files | |
wget http://download.redis.io/releases/redis-$VER.tar.gz | |
tar -xzf redis-$VER.tar.gz | |
cd redis-$VER | |
# Compile | |
make install | |
# Create a user account for Redis | |
sudo adduser --system --no-create-home --disabled-login --disabled-password --group redis | |
# Make a writable log file | |
sudo touch /var/log/redis.log | |
sudo chown redis:redis /var/log/redis.log | |
sudo chmod u+w /var/log/redis.log | |
# Make an init script | |
cd /etc/init.d/ | |
wget https://gist.github.com/peterc/408762/raw -O redis | |
sudo chmod u+x redis | |
sudo update-rc.d -f redis defaults | |
# Make a place to store your database | |
sudo mkdir /var/redis | |
sudo chown redis:redis /var/redis | |
sudo chmod u+xw /var/redis | |
sudo mkdir /etc/redis | |
sudo touch /etc/redis/redis.conf | |
sudo chown redis:redis -R /etc/redis/ | |
echo "daemonize yes | |
pidfile /var/run/redis.pid | |
logfile /var/log/redis.log | |
port 6379 | |
# bind 127.0.0.1 | |
# unixsocket /tmp/redis.sock | |
timeout 300 | |
loglevel verbose | |
databases 16 | |
save 900 1 | |
save 300 10 | |
save 60 10000 | |
rdbcompression yes | |
dbfilename dump.rdb | |
dir /var/redis/ | |
# requirepass foobared" > /etc/redis/redis.conf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One important note:
In case you have redis server and other clients inside /usr/local/bin you have to change config file. This is case for Debian distribution.
nano /etc/init.d/redis
and change this line
DAEMON=/usr/bin/redis-server
toDAEMON=/usr/local/bin/redis-server
Now you can start the service with
sudo service redis start
connect to your redis with cli like this
redis-cli