sudo apt update and sudo apt install redis-server. The service starts by itself and listens only on 127.0.0.1 port 6379. Test it with redis-cli ping, which answers PONG. Then set a password and a memory limit in /etc/redis/redis.conf and restart with sudo systemctl restart redis-server.
Before you start
- You need a user with
sudorights. If you are logged in asroot, leave outsudo. - Redis is an in-memory data store: it keeps data in RAM, so it is very fast. Apps use it as a cache, for sessions or for job queues (for example WordPress object caching, Laravel or Discord bots).
- Plan how much RAM Redis may use. See check memory usage.
How to install Redis
- Ubuntu / Debian
- AlmaLinux / Rocky 9
- AlmaLinux / Rocky 10
1
Install the package
2
Check the service
active (running). Press q to leave.How to check Redis works
"hello".
How to secure Redis
The Redis security guide warns that it is “not a good idea to expose the Redis instance directly to the internet”. On Ubuntu and Debian the config already has safe defaults:bind keeps Redis on the server itself. Protected mode makes Redis refuse outside clients when it has no password. Leave both as they are.
How to set a Redis password
1
Edit the config
# requirepass foobared and add below it:2
Restart Redis
redis.3
Test it
NOAUTH Authentication required. Log in with redis-cli --askpass, type the password, then run ping again.requirepass is the simple, legacy method that gives one password to every client. Redis 6 and later also support named users with their own rights through ACLs (access control lists), which Redis recommends for larger setups.
How to limit Redis memory
Without a limit, Redis keeps growing until the server runs out of RAM. In/etc/redis/redis.conf, set:
allkeys-lru removes the least recently used keys when the limit is reached, which suits a cache. Keep the default noeviction if Redis stores data you must not lose, such as queues. Restart Redis after the change.
Frequently asked questions
Where are Redis logs and data stored on Ubuntu?
The log is/var/log/redis/redis-server.log and data files are saved in /var/lib/redis.
Is Redis data lost on restart?
Not by default, but you can lose changes made since the last snapshot. Redis 7.0 saves a snapshot after 3600 seconds if at least 1 key changed, after 300 seconds if 100 changed, or after 60 seconds if 10,000 changed. Setappendonly yes to log every write for stronger durability.
How do I connect PHP to Redis?
Install the PHP extension, for examplesudo apt install php-redis, then restart PHP-FPM. Point your app at 127.0.0.1 port 6379 with your password.
Can I run Redis in Docker instead?
Yes. See install Docker and use Docker Compose. Do not publish port6379 to the internet.
Related guides
VPS and dedicated server guides
Every guide in this section.
Install PostgreSQL
A database to pair with Redis.
Install WordPress on a VPS
Use Redis for object caching.
Host a Discord bot
Bots often keep state in Redis.
Check open ports
Confirm 6379 is not public.
Checked against the official Redis documentation and Redis security guide on 4 November 2026; install,
redis-cli, password and memory settings tested on Ubuntu 24.04 LTS with Redis 7.0. Commands can differ on other distributions or releases.Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026