Updated June 2026. Tested on Laravel 13, PHP 8.4 and Ubuntu 24.04.
Redis is an in memory data store, which makes it far faster than a disk backed database for the things Laravel uses it for: cache, sessions and queues. Putting your cache and sessions in Redis is one of the easiest performance wins you get. This guide installs Redis on Ubuntu and wires it into Laravel the modern way.
Install Redis
On Ubuntu it is one package. The old days of compiling from source are behind us.
sudo apt update
sudo apt install redis-server -y
sudo systemctl enable --now redis-server
Check it answers.
redis-cli ping # PONG
By default Redis binds to localhost only, so it is not exposed to the internet. On a single server with a firewall blocking outside traffic, that is safe as is. If Redis is on its own server, or you want belt and braces, set a password in /etc/redis/redis.conf with the requirepass directive and restart the service.
Install the PHP extension
Laravel talks to Redis through PHP. The recommended client today is the phpredis extension, which is written in C and faster than the older predis PHP library.
sudo apt install php8.4-redis -y
php -m | grep redis
If redis shows in the list, you are set. You do not need to composer require predis/predis anymore unless you specifically want the PHP client.
Configure Laravel
Redis is already defined in config/database.php, defaulting to the phpredis client.
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD'),
'port' => env('REDIS_PORT', '6379'),
'database' => env('REDIS_DB', '0'),
],
],
The real switch happens in .env. Point cache, sessions and queues at Redis.
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
CACHE_STORE=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis
Clear the config cache so the new settings take hold.
php artisan config:clear
Try it
Cache something and read it back to confirm the wiring.
use Illuminate\Support\Facades\Cache;
Cache::put('greeting', 'Hello from Redis', now()->addMinutes(10));
$value = Cache::get('greeting');
You can also watch it land in Redis directly.
redis-cli
> keys *
A note on multiple apps on one server
If two Laravel apps share one Redis server, give each its own database number (REDIS_DB) and a cache prefix, so they do not step on each other's keys. Laravel sets a prefix from your app name by default, which usually handles this for you.
That is Redis ready for Laravel: install the server, add the phpredis extension, and point cache, sessions and queues at it in .env. Questions welcome in the comments.
All comments ()
No comments yet
Be the first to leave a comment on this post.