Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Using Unix Sockets with Redis

darkalchemy edited this page Jun 26, 2020 · 2 revisions

To use sockets with redis effectively, you need to ensure both the redis user and www-data user can read and write to the socket file.

I use '/dev/shm' since its in ram and should be faster to connect to, you can change this to any location, as needed.

I have read that connecting via socket can be as much as 30% faster than through TCP.

redis.conf

port 0
unixsocket /dev/shm/redis.sock
unixsocketperm 664

php.ini

session.save_handler = redis
session.save_path = "unix:///dev/shm/redis.sock?database=2"
sudo usermod -a -G redis www-data
sudo usermod -a -G www-data redis

After this, you may need to restart the server for this to take effect.

Clone this wiki locally