In this article, we will show you how to install and configure Redis on a Debian VPS. Redis is an open source, in-memory data structure store with support for disk persistency. It is a key-value distributed database that supports data structures such as Strings, Lists, Sets, Sorted Sets, Hashes, HyperLogLogs, Bitmaps.
The Redis package that comes with Debian repo is quite outdated and contains a lot of security vulnerabilities. In this guide, we will install Redis from the source. At the time of this writing, the latest stable version of Redis is 4.0.8. Installing Redis on Debian 9 is fairly easy task, if you carefully follow the steps in the tutorial below. Let’s get started with the installation.
1. Update the Os packages
$ sudo apt-get update $ sudo apt-get upgrade
2. Install dependencies
In order to compile from source, we need to install the build tools:
$ apt-get install build-essential tcl wget curl
Download Redis source from the official site:
$ wget http://download.redis.io/redis-stable.tar.gz
Extract the compressed file to a directory on your server.
$ tar xvzf redis-stable.tar.gz $ cd redis-stable
Previous versions up until 4.0, Redis requires compiling separate components. Now with version 4, compiling Redis also compiles the needed dependencies.
Compile the source.
Next, after redis has been compiled, install the required binaries onto the server.
$ make install
Optionally you can run below command to test whether Redis binaries and its dependencies have been met.
$ make test
3. Starting Redis
The Redis source package we have downloaded earlier comes with useful utilities that automates the process of starting up redis during system boot.
Change into utils directory and execute the build script. The script runs interactively, just accept the default values when prompted.
$ cd utils/ $ ./install_server.sh
The script above installs relevant start up scripts suitable for the server. Also, the default Redis configuration file is located at /etc/redis.conf.
Enable Redis during start up
$ systemctl enable redis_6379
$ systemctl start redis_6379
4. Test Redis Installation
Redis comes with a binary redis-cli which can be used to talk to redis. By default redis listens to port 6379 via tcp.
Check if redis is running
$ netstat -ln | grep 6379
You should see an output similar to the following:
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN
Another way of testing Redis is running redis-cli command without any arguments
You can test connectivity using ping command
redis 127.0.0.1:6379> ping
You can also use the echo command to display some string just like a regular echo command
redis 127.0.0.1:6379> echo “LinuxCloudVPS”
You should see the following output like this:
That’s it. You now have a working Redis instance on your virtual server which can be used by your applications.
Of course, you don’t have to install and configure Redis on a Debian server, if you use one of our Redis ready VPS Hosting services, in which case you can simply ask our expert Linux admins to install and configure Redis on a Debian server, for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post, on how to install and configure Redis on a Debian server, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.