Redis Print

  • 0

How to Install and Configure Redis on Ubuntu 24.04 Manually

Article Type: Installation Guide

Difficulty: Beginner

Operating System: Ubuntu 24.04 LTS


Introduction

This guide explains how to manually install and configure Redis Server on Ubuntu 24.04. These steps perform the same tasks as the Ansible playbook but are entered manually in the terminal.

Redis is an in-memory database that stores data in memory, making applications much faster. It is commonly used for caching, session storage, and message queues.


Prerequisites

  • Ubuntu 24.04 Server
  • User account with sudo privileges
  • Internet connection
  • Terminal access

Step 1 - Update the Package List

Update Ubuntu before installing Redis.

sudo apt update

If updates are available, install them.

sudo apt upgrade -y

Step 2 - Install Redis Server

Install Redis using the Ubuntu package manager.

sudo apt install redis-server -y

Step 3 - Verify Redis Installation

Check that Redis was installed successfully.

redis-server --version

Example output:

Redis server v=7.x.x

Step 4 - Edit the Redis Configuration File

Open the Redis configuration file.

sudo nano /etc/redis/redis.conf

Step 5 - Configure the Bind Address

Locate the line:

bind 127.0.0.1

Ensure it is set to:

bind 127.0.0.1

Step 6 - Enable Protected Mode

Find:

protected-mode

Set it to:

protected-mode yes

Step 7 - Configure the Redis Port

Locate:

port

Ensure it is set to:

port 6379

Step 8 - Disable Daemon Mode

Locate:

daemonize

Change it to:

daemonize no

Step 9 - Set a Redis Password

Find the line:

# requirepass foobared

Replace it with:

requirepass ChangeMe123!

Note: Replace ChangeMe123! with your own strong password.


Step 10 - Save the Configuration File

  • Press Ctrl + O
  • Press Enter
  • Press Ctrl + X

Step 11 - Install UFW Firewall

sudo apt install ufw -y

Step 12 - Allow SSH Connections

sudo ufw allow OpenSSH

Step 13 - Block External Access to Redis

Prevent remote users from connecting directly to Redis.

sudo ufw deny 6379/tcp

Step 14 - Enable the Firewall

sudo ufw enable

Verify the firewall status.

sudo ufw status

Step 15 - Enable Redis to Start Automatically

sudo systemctl enable redis-server

Step 16 - Restart Redis

sudo systemctl restart redis-server

Step 17 - Check the Redis Service

sudo systemctl status redis-server

You should see:

Active: active (running)

Step 18 - Test Redis

Connect to Redis and test it.

redis-cli -a ChangeMe123! ping

If Redis is working correctly, the output will be:

PONG

Step 19 - Save the Redis Database

Save the current data to disk.

redis-cli -a ChangeMe123! save

You should receive:

OK

Step 20 - Check That Redis Is Listening

sudo ss -tlnp | grep 6379

Example output:

LISTEN 0 511 127.0.0.1:6379

Step 21 - Display the Redis Version

redis-server --version

Verification Checklist

Verification Expected Result
Redis Installed Success
Redis Service Running
Firewall Enabled Enabled
Password Configured Yes
Redis Test PONG
Database Saved OK

Troubleshooting

Redis Service Failed to Start

sudo systemctl status redis-server

View detailed logs:

sudo journalctl -u redis-server

Authentication Error

If you receive:

NOAUTH Authentication required.

Reconnect using the password:

redis-cli -a ChangeMe123!

Redis Is Not Listening

Restart the service.

sudo systemctl restart redis-server

Conclusion

You have successfully installed and configured Redis Server on Ubuntu 24.04.

The Redis service is now:

  • Installed
  • Secured with a password
  • Running automatically at startup
  • Protected by the firewall
  • Ready to be used by applications such as ERPNext, Nextcloud, Laravel, Django, Node.js, and many others.

Important Note

Redis is not a web application, so it does not provide a browser URL like ERPNext or OrangeHRM. You access Redis using the redis-cli command or through applications that connect to Redis on port 6379.


Ha estat útil la resposta?
Back