This article explains the setup and configuration of the Redis server in Linux, Ubuntu, and Unix.
- How to install the Redis server
- Uninstall the Redis server
- Upgrade the Redis server
- Start, Stop and Restart the Redis server
Redis has a package for all distributions of Linux and Unix flavors.
homebrew is a package manager for managing the packages in MACOS. It automates the process for easy setup and configuration on macOS. It provides a brew command to start, stop, installation of Redis server.
You can also install Redis without the brew command.
How to install Redis server in Linux, Ubuntu
- On Ubuntu Installation The first step, update all your local packages to the latest.
sudo apt update
Next, Run the Redis server using apt command.
sudo apt install redis-server
It installs to the local folder in ubuntu.
- On Linux Installation: The first step, update all your local packages to the latest.
sudo apt-get update
Next, Run the Redis server using the
sudo apt-get install redis-server
For yum users
yum install redis
Redis server installation folder location:
You can find the location of the Redis installation folder using the
$127.0.0.1:6379> config get dir
You can also use the
which redis-server command to get the installation folder.
Once you find the location, Open configuration file
Redis.conf as given below.
sudo nano /usr/local/var/redis/redis.conf
sudo vi /usr/local/var/redis/redis.conf
Change the supervised to systemd to allow running Redis as a service.
Save the file and restart the server. From here, Redis started as a service, you can restart with service.
You can verify redis server is running or not using the below command.
sudo systemctl status redis
Also, Verify redis-cli using the below command.
It connects to the Redis server and starts the interactive shell command prompt. It gives current running server information.
How to restart the redis server in Linux
To stop the redis server.
sudo service redis stop
sudo systemctl stop redis
To start the redis server.
sudo service redis start
sudo systemctl start redis
To restart the redis server.
sudo service redis restart
sudo systemctl restart redis
Upgrade Redis 5 to the latest
First, take backup of redis database, next, uninstall and install redis server.
yum uninstall redis
yum install redis
How to run Redis Server as Daemon background in Linux
Redis runs as a separate process and does not run in background by default.
There are multiple ways we can do
- using –daemonize option
redis-server --daemonize yes
- using nohup
nohup redis-server &