Skip to content

Redis Install

Javier Gusano Martinez edited this page Nov 30, 2016 · 6 revisions

Redis Installation Process

Download, extract and compile last version of Redis. This is an example with the last version at the moment of this tutorial has write:

$ sudo apt-get install build-essential
$ wget http://download.redis.io/redis-stable.tar.gz
$ tar xzf redis-stable.tar.gz
$ cd redis-stable
$ make

Note: If something goes wrong during installation process, try with this command:

$ make distclean

Check Redis

The binaries compiled are available under 'src' directory. Run Redis with:

$ src/redis-server

You can interact with Redis using the built-in client:

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

Redis Security Configuration

Open the Redis configuration file using an editor like nano:

nano $HOME/redis-stable/redis.conf

Delete the first # symbol for the bind parameter and set it according to your requirements:

  • Localhost access: bind 127.0.0.1
  • Remote access: If you need to access to the Redis database remotely, take additional security actions for protect your private keys. For example, using a Firewall. The bind field should be: bind PUT_HERE_YOUR_REMOTE_REDIS_SERVER_IP

The easy way to restrict Redis access only to localhost connections is changing 'bind' parameter on configuration file to this:

bind 127.0.0.1

Note: "Bind" parameter is commented by default. It means Redis accepts all incoming connections.

Finally, enable Redis for use password for the incoming connections. Remove the # symbol for the following line:

requirepass foobared

Change the foobared string with your own password. Save the changes and continue this tutorial.

Redis Auto-start

Configure Redis for automatic start using Crontab. Open the Crontab editor with this command:

$ crontab -e

Insert the following line:

@reboot $HOME/redis-stable/src/redis-server $HOME/redis-stable/redis.conf

Clone this wiki locally