Issue
I have installed Redis 3.0.6 on Debian. There's a /etc/init.d/redis
file which starts the Redis server when the system starts or I can invoke it manually to start/stop the server. Problem is that this script is run as root user.
I have a redis
user and group that I want to make Redis run under. But I can't figure out how (I have not found an option to make Redis switch user ID after startup). In my config file I use
unixsocket /home/redis/redis.sock
unixsocketperm 770
But, of course, the redis.sock
is owned by root
.
drwxr-xr-x 2 redis redis 4096 Jan 18 03:34 bin
drwxr-xr-x 2 redis redis 4096 Jan 18 03:55 data
-rw-r--r-- 1 redis redis 41638 Jan 18 03:52 redis.conf
-rw-r--r-- 1 redis redis 16348 Jan 18 03:55 redis.log
-rw-r--r-- 1 root root 5 Jan 18 03:55 redis.pid
srwxrwx--- 1 root root 0 Jan 18 03:55 redis.sock
And the process is, too.
root 7913 0.1 0.1 38016 1976 ? Ssl 03:55 0:00 /home/redis/bin/redis-server *:6379
Ultimately, I have a git
user that is also in the redis
group and thus should in the end have access to redis.sock
. (This is for a manual deployment of GitLab CE).
How I can I configure the Redis server that way?
Solution
Update your /etc/init.d to use sudo
during start service (line 33):
sudo -u redis $EXEC $CONF
You may need to cleanup old files (in /var/lib
) or reset their permission to redis.
Answered By - Ali Nikneshan