Redis server on openSUSE
Installation
sudo zypper in redis
Configuration
Copy default config file
sudo cp -a /etc/redis/default.conf.example /etc/redis/instancename.conf
We use the cp -a here, so that our permissions are preserved.
In case you copied the file without the -a:
sudo chown root:redis /etc/redis/instancename.conf
sudo chmod u=rw,g=r,o= /etc/redis/instancename.conf
Add user to redis group with YaST, logout and login.
Minimal config
Change at least pidfile, logfile and dir setting the pid file has to match your config filename without the .conf
pidfile /run/redis/instancename.pid
logfile /var/log/redis/instancename.log
dir /var/lib/redis/instancename/
If you want to run more than one instance you also have to change the socket path and/or the ip:port combination.
e.g. /run/redis/instancename.sock
Also make sure if you copy configurations from somewhere, that daemonize should be set to no.
Create the database dir
sudo install -d -o redis -g redis -m 0750 /var/lib/redis/instancename/
sudo systemctl start redis@instancename
sudo systemctl enable redis@instancename
To stop/restart all instances at the same time use:
sudo systemctl restart redis.target
sudo systemctl stop redis.target
Default config
bind 127.0.0.1 -::1
protected-mode yes
port 6379
Use Unix socket
Add this in conf file:
unixsocket /var/run/redis/instancename.sock
unixsocketperm 775
Integration with apache when using unix domain sockets
If you plan to use redis in combination with apache, then you should
add redis to apache group and set unixsocketperm 770:
sudo usermod -a -G redis wwwrun
sudo systemctl restart apache2
apache is now able to connect to the redis socket.
