PHP Redis with socket connection

if you are using Redis on a single server and/or want the web server at the same location to use sockets instead of TCP, update your redis config (redis.conf) to include:

unixsocket /var/run/redis/redis.sock

(you may be able to just uncomment that line to use the default)

You will need to make sure the socket connection has the correct permissions for the apache/php service. You can set the “unixsocketperm” attribute in redis.conf and make sure the socket location is appropriate for your apache/php set-up, or you can add a line in your redis start-up script to update the permissions, something like this:

chown :apache $SOCK && chmod g+w $SOCK

I’m not sure what the best practice is here, but I needed to do one the above to get it to work.

Leave a Reply