Skip to content

Instantly share code, notes, and snippets.

Created March 24, 2013 02:01
Show Gist options
  • Save anonymous/5230133 to your computer and use it in GitHub Desktop.
Save anonymous/5230133 to your computer and use it in GitHub Desktop.
Setup Redis as a service Ubuntu 12.04, 12.10

Install Redis 2.6 as a Service on Ubuntu

  1. Install Ubuntu updates, set time zones, followed by GCC and Make
sudo apt-get update
sudo apt-get -y install build-essential
  1. Install tcl8.5 for Redis
sudo apt-get -y install tcl8.5
  1. Download, Untar and Make Redis 2.6
wget http://redis.googlecode.com/files/redis-2.6.11.tar.gz
tar xzf redis-2.6.11.tar.gz
cd redis-2.6.11
make
make install
make test
  1. Create Directories and Move Redis Config File
sudo mkdir /etc/redis
sudo mv redis.conf /etc/redis/redis.conf
  1. Configure Redis.Conf
sudo nano /etc/redis/redis.conf
[..]
daemonize yes
[..]
[..]
bind 127.0.0.1
[..]
[..]
dir /var/lib/redis
[..]
  1. Download init Script, and Move Redis Server From the Redis Directory:
cd src
wget https://gist.github.com/anonymous/5230129/raw/e21c9fc6a8c44b96df8c5df14dab55eb7ca1f44d/redis-server
sudo mv redis-server /etc/init.d/redis-server
sudo mv redis-cli /etc/init.d/redis-cli
sudo chmod +x /etc/init.d/redis-server
  1. Change Redis-Server Settings
nano /etc/init.d/redis-server
[..]
DAEMON=/usr/local/bin/redis-server
[..]
  1. Create Redis User and Log Files
sudo useradd redis
sudo mkdir -p /var/lib/redis
sudo mkdir -p /var/log/redis
sudo chown redis.redis /var/lib/redis
sudo chown redis.redis /var/log/redis
  1. Auto-Enable Redis-Server
sudo update-rc.d redis-server defaults
  1. Start Redis Server
sudo /etc/init.d/redis-server start

In general, the following commands can be used to start, stop, or restart redis-server:

sudo /etc/init.d/redis-server start (stop) (restart)

Or,

sudo service redis-server start (stop) (restart)
  1. And Finally, to Use Redis Command Line
cd /etc/init.d
./redis-cli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment