Install Redis normally
Add the user to the Redis group
usermod -a -G redis YourUserHere
Open up the CageFS mount points file
nano /etc/cagefs/cagefs.mp
Add the Redis folder to the mount points.
/var/run/redis
Enable the socket in the Redis config file
nano /etc/redis.conf
Add the following:
unixsocket /var/run/redis/redis.sock unixsocketperm 770
Every time you restart Redis the socket will disappear from the CageFS, breaking all the code using the socket, we can add extra commands to the Redis systemd unit to automatically restore it.
This is completely optional if your Redis never crashes/needs restarting, but will save headaches otherwise. The + in the command makes the command run as root, which is needed to update the CageFS skeleton.
nano /etc/systemd/system/redis.service.d/restore.cagefs.socket.conf
Add:
[Service] ExecStartPost=+cagefsctl --force-update ExecStartPost=+cagefsctl -M
Reload systemd
systemctl daemon-reload
You can now safely restart Redis as you would normally and the users you’ve added to the Redis group will be able to use sockets at /var/run/redis/redis.sock
This method was used to make sockets work with the wonderful XenForo Redis Addon from Xon if you used this guide, you can them enable it by opening src/config.php and adding:
// setup Redis caching $config['cache']['enabled'] = true; $config['cache']['provider'] = 'SV\RedisCache\Redis'; $config['cache']['namespace'] = 'SomePrefix'; $config['cache']['config'] = [ 'host' => '/var/run/redis/redis.sock', 'use_lua' => true, 'serializer' => 'igbinary', // most CloudLinux installs should have this enabled, if your site presents a white screen after adding this, set to 'php' 'database' => 1, ];
Leave a Reply