How To Install Redis on Ubuntu 22.04
Redis:
Redis (REmote DIctionary Server) is an open source, in-memory, NoSQL key/value store that is used primarily as an application cache or quick-response database.
Getting started with Redis
1. System Update
sudo apt update
sudo apt upgrade -y2. Add Redis Official APT Repository
Install required packages:
sudo apt-get install lsb-release curl gpg -yImport Redis GPG key:
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpgSet correct permissions:
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpgAdd Redis repository to APT sources:
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.listUpdate APT cache:
sudo apt-get update2. Add Redis Official APT Repository
sudo apt-get install redis -y4. Enable Redis Service
sudo systemctl enable redis-server
sudo systemctl start redis-server
sudo systemctl status redis-server
5. Test Redis Service
redis-cli
pingExpected output:
PONG
Exit:
exit6. Configure Redis for systemd & Security
Open configuration file:
sudo nano /etc/redis/redis.conf6.1 Enable systemd supervision
Search or manually add:
supervised systemd6.1 Enable systemd supervision
Find:
# requirepass foobaredUncomment and modify:
requirepass <YourStrongPassword> #set your db password6.3 (Optional) Enable Remote Access
Only if required for external applications:
bind 0.0.0.0Save and exit (CTRL+O, Enter, CTRL+X)
Restart Redis:
sudo systemctl restart redis-server6.3 (Optional) Enable Remote Access
redis-cli
AUTH <YourStrongPassword>
pingOutput:
PONGLast updated