How to install Redis on Ubuntu

How to Ubuntu

← Prev

In this tutorial we will learn to install Redis on Ubuntu.

This steps will work for Ubuntu 16 and newer versions like 18.04 LTS.

Step #1: Update

Before we start installing Redis on our Ubuntu machine let us go ahead and update the packages.

Open Terminal and run the following command.

$ sudo apt update

Note! In the above command we are using sudo so, you will be prompted to enter your password.

If any package needs an upgrade then run the following command.

$ sudo apt upgrade

Alright, let's install Redis server.

Step #2: Install Redis server

To install Redis server we will run the following command.

$ sudo apt install redis

On successful installation we can check the version of the Redis server by running the following command.

$ redis-server -v
Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=1bc80a08306a3efd

Note! At the time of writing this tutorial I was using v4.0.9 Redis server.

Tips

Redis CLI

To connect to the Redis server we use the redis-cli command.

$ redis-cli
127.0.0.1:6379>

By default, Redis will run on port 6379.

PING and PONG

If we run PING command in redis-cli we will get back PONG response. This means redis is working.

127.0.0.1:6379> PING
PONG

Exit redis-cli

To exit redis-cli run the following command.

127.0.0.1:6379> exit

Enable Redis server

Run the following command to enable Redis server to start at bootup time.

$ sudo systemctl enable redis-server

Disable Redis server

Run the following command to disable Redis server from starting at bootup time.

$ sudo systemctl disable redis-server

Restart Redis server

To restart Redis server run the following command.

$ sudo service redis-server restart

Alright, this bring us to the end of this tutorial. Please share this tutorial if you find it useful.

Thanks for reading. See you next time :-)

← Prev

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT