July 21, 2017

Using Redis

We'll install the latest stable version of Redis and set up Laravel to use it.

Previous: Setting Up MySQL

We'll get the latest Redis installed and configured within Laravel.

Install

We can optionally get a repository to get the latest stable version of Redis:

sudo add-apt-repository -y ppa:chris-lea/redis-server

sudo apt-get update

sudo apt-get install -y redis-server

Config Laravel

Once that's installed, it's pretty much ready to go. All we need to do is configure our application to use it.

To do that in Laravel, all we need to do is edit the .env file and set the cache/session drivers to use redis. The redis connection information is preset for us for localhost connections.

CACHE_DRIVER=redis
SESSION_DRIVER=redis

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

All Topics