Install Redis on Linux
How to install Redis on Linux
Most major Linux distributions provide packages for Redis.
Install on Ubuntu/Debian
sudo apt-get update
sudo apt-get install redisRedis will start automatically, and it will restart at boot time.
Install on Red Hat/Rocky
sudo yum install redis
sudo systemctl enable redis
sudo systemctl start redisRedis will restart at boot time.
Install on Ubuntu using Snap
To install via Snap, run:
sudo apt update
sudo apt install redis-tools # for redis-cli
sudo snap install redisRedis will start automatically, but it won't restart at boot time. To do this, run:
sudo snap set redis service.start=trueYou an use these additional snap-related commands to start, stop, restart, and check the status of Redis:
sudo snap start redissudo snap stop redissudo snap restart redissudo snap services redis
If your Linux distribution does not currently have Snap installed, you can install it using the instructions described here. Then, consult the Snapcraft store for instructions on installing Redis using Snap for your distribution.
Starting and stopping Redis in the background
You can start the Redis server as a background process using the systemctl command. This only applies to Ubuntu/Debian when installed using apt, and Red Hat/Rocky when installed using yum.
sudo systemctl start redisTo stop the server, use:
sudo systemctl stop redisConnect to Redis
Once Redis is running, you can test it by running redis-cli:
redis-cliTest the connection with the ping command:
127.0.0.1:6379> ping
PONGYou can also test that your Redis server is running using Redis Insight.
Next steps
Once you have a running Redis instance, you may want to:
- Try the Redis CLI tutorial
- Connect using one of the Redis clients
- Install Redis "properly" for production use.