Configure the service script
There is a redis_init_script file under redis-4.0.2/utils, which is the service script for Sysvinit.

sudo cp utils/redis_init_script /etc/init.d/redisd

As the name of the system startup service (end with D to indicate self-startup service, convention).
Open a file Change the startup directory of the file

sudo vim /etc/init.d/redisd

REDISPORT=6379EXEC=/usr/local/redis/bin/redis-server

CLIEXEC=/usr/local/redis/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid

CONF=”/etc/redis/${REDISPORT}.conf”



2. Configuration files
Conf file in the root directory, copy and change the name. Note that this name corresponds to the /etc/redis/${REDISPORT}.conf configuration.

sudo mkdir /etc/redissudo cp redis.conf /etc/redis/6379.conf

Open the file and modify the content as follows:

Logfile /var/log/redis/redis-server.log # set persistent file dir /var/lib/redis

Note: the above directories are not available, you need to create folders afterwards

sudo mkdir /var/log/redissudo mkdir /var/lib/redis



Update-rc. d

D /redisd defaults sudo chmod +x /etc/init.d/ redreary # register service CD /etc/init.d/sudo update-rc.d redisd defaults

4. Common service commands

Sudo service redisd start sudo service redisd stop

5, line fault
You can run the /etc/init.d/redisd start command and check the logs in the /var/log/redis/ directory to rectify errors. The directory is the directory specified by the service script.

For more technical information: Gzitcast